When using the exec
component is it possible to specify args inline rather than having to set them in the ExecBinding.EXEC_COMMAND_ARGS
?
For example I have this Route:
from("seda:getPolicyListStart")
.process(new Processor() {
public void process(Exchange e) {
ClientRequestBean requestBean = (ClientRequestBean)e.getIn().getBody();
List<String> args = new ArrayList<String>();
args.add(requestBean.getClient());
args.add(requestBean.getSort());
e.getOut().setHeader(ExecBinding.EXEC_COMMAND_ARGS, args);
}
})
.to("exec:some_command?useStderrOnEmptyStdout=true")
.convertBodyTo(String.class)
.log("Executed OS cmd and received: ${body}")
However I would have thought that I could use the Simple Expression Language to simplify it like so:
from("seda:getPolicyListStart")
.to("exec:some_command?useStderrOnEmptyStdout=true&args=${body.client} ${body.sort}")
.convertBodyTo(String.class)
.log("Executed OS cmd and received: ${body}")
Similar to how you can use File Language (a subset of Simple) when you use the File Component.
Is it possible? If not, can the first example be simplified?
The answer is in the EIP patterns. You need to use the dynamic recipient list EIP pattern when you compute an endpoint destination at runtime.
http://camel.apache.org/recipient-list.html
The recipient list accepts an expression which means you can use the Simple language to construct the parameters at runtime