When using the exec component, you can specify args inline strings instead of setting them to 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 a simple expression language to simplify it like this:
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 use File Language (a subset of Simple) when you use the File component.
Is it possible? If not, can the first example be simplified?
UPDATE [solution]:
from(requestNode) .routeId(routeId) .recipientList(simple("exec:"+osCmd+"?useStderrOnEmptyStdout=true&args=${body.client}")) .convertBodyTo(String.class) .log("Executed OS cmd and received: ${body}") .to(responseNode);
Thanks.
source share