I wanted to implement a camel DSL logic where eg I have two routes where the request received for first route should be passed to second route along with the response from first route. How do I achieve this?
`.to("direct:validatePayload")
.to("bean:fundService?method=depositFund(${exchange})")
.to("bean:rparticipantService?method=notifyParticipant(${exchange})");`
In the above code, after validating the request payload, the exchange which has the Fund body is passed as request to depositFund. After this, I wanted to pass the request to notifyParticipant which will be combination of response from depositFund along with the request that depositFund received. How do I achieve this through camel DSL code.
Take a look at Message History: https://cwiki.apache.org/confluence/display/CAMEL/Message+History
In the rparticipantService#notifyParticipant
you should be able to lookup history and get results of fundService#depositFund
.
List<MessageHistory> list = exchange.getProperty(Exchange.MESSAGE_HISTORY, List.class);
Also you will need to tune MessageHistoryFactory
to be able to access the message + body:
camelContext.getMessageHistoryFactory().setCopyMessage(true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.