Hi I have a route which is
<route id="invokeGetMortgageAccountDetails">
<from uri="direct:invokeGetMortgageAccountDetails" />
<removeHeaders pattern="operationNamespace" />
<setHeader headerName="operationName">
<constant>getMortgageDetailsRequest</constant>
</setHeader>
<to uri="cxf:bean:getBastionAcctDetailsClient" />
<removeHeaders pattern="*" />
</route>
Now i want to change the 'to uri' if length of parameter account is equal to 8.
I am new to Apache camel and there is not very helpful information on internet.
I am using camel version 2.15 and i tried passing an extra property called length of account number in exchange and tried to match with value in route but it did not work.
Processor:
public void processMortgage(final Exchange exchange) throws ServiceException { MessageContentsList messageContentsList = (MessageContentsList) exchange.getIn().getBody(); List paramsList = new ArrayList(); String systemID = messageContentsList.get(0).toString().trim(); String brandID = messageContentsList.get(1).toString().trim(); String account = messageContentsList.get(2).toString().trim(); String len = Integer.toString(account.length()); paramsList.add(Constants.HUB); paramsList.add(brandID.toUpperCase()); paramsList.add(account); exchange.setProperty(Constants.SystemID, systemID); exchange.setProperty(len, len); exchange.setProperty(Constants.ErrorCode, null); exchange.setProperty("mortgageAccountNumber", Integer.parseInt(account)); } exchange.getIn().setBody(paramsList); }
Route Config:
<route id="invokeGetMortgageAccountDetails">
<from uri="direct:invokeGetMortgageAccountDetails" /> <removeHeaders pattern="operationNamespace" />
<setHeader headerName="operationName">
<constant>getMortgageDetailsRequest</constant> </setHeader> <choice>
<when>
<simple>${body.len} == '8'</simple>
<to uri="cxf:bean:getPhoebusClient" />
</when>
<otherwise>
<to uri="cxf:bean:getBastionAcctDetailsClient" />
</otherwise>
</choice>
<removeHeaders pattern="*" />
</route>