Reputation: 1906
I'm trying to set some properties in my process method but I'm not able to figure out that how to use those properties in xml, like I can use header values in xml easily by using syntax : ${in.header.myKey}
Here's my code :
<route>
<from uri="activemq:queue:start.queue" />
<to uri="stream:out" />
<process ref="jsonProcessor"></process>
<to uri="bean:validateInputIdentifiers?method=validation(${in.property.SourceMap}, ${in.property.DestinationMap})" />
</route>
Here in.property.SourceMap is Unknown function. What is the correct way? Would be great if it is something similar to header. Also I want to use property only and not header since values of header may not persists later in my routes.
Here's process method code:
@Override
public void process(Exchange exchange) throws Exception {
List<Map<String, String>> body = exchange.getIn().getBody(List.class);
Map<String, String> sourceMap = body.get(0);
Map<String, String> destinationMap = body.get(1);
exchange.setProperty("SourceMap", sourceMap);
exchange.setProperty("DestinationMap", destinationMap);
}
Kindly provide the solution.
Upvotes: 2
Views: 4278
Reputation: 2007
There could be multiple solution combinations for your problem.
Sample Property Key and Value.
<cm:property name="app.user" value="PROD008"/>
In Route if u want to set header with property value. Use below code snippet.
<setHeader headerName="password">
<simple>${properties:app.user}</simple>
</setHeader>
If you want to use property, you can use below snippet.
<to uri="{{some.endpoint}}"/>
For your example: if Properties are SourceMap and DestinationMap you can use any of below.
1. <to uri="bean:validateInputIdentifiers?method=validation(${property.SourceMap}, ${property.DestinationMap})" />
2. <to uri="bean:validateInputIdentifiers?method=validation({{SourceMap}},{{DestinationMap}})" />
If you want to use header instead of property then use below code snippet.
<to uri="bean:validateInputIdentifiers?method=validation(${header.SourceMap}, ${header.DestinationMap})" />
Upvotes: 6
Reputation: 1906
After hit and trial I got the working solution:
<route>
<from uri="activemq:queue:start.queue" />
<to uri="stream:out" />
<process ref="jsonProcessor"></process>
<to uri="bean:validateInputIdentifiers?method=validation(${property.SourceMap}, ${property.DestinationMap})" />
</route>
Upvotes: 2