我想实现一个骆驼DSL逻辑,例如,我有两条路由,其中第一条路由收到的请求应与第一条路由的响应一起传递到第二条路由。我该如何实现?
`.to("direct:validatePayload")
.to("bean:fundService?method=depositFund(${exchange})")
.to("bean:rparticipantService?method=notifyParticipant(${exchange})");`
在上面的代码中,在验证了请求有效负载之后,将具有基金主体的交易所作为请求传递给depositFund。之后,我想将请求传递给notifyParticipant,这将是depositFund的响应与depositFund收到的请求的组合。如何通过骆驼DSL代码实现这一目标。
答案 0 :(得分:0)
看看消息历史记录:https://cwiki.apache.org/confluence/display/CAMEL/Message+History
在rparticipantService#notifyParticipant
中,您应该能够查找历史记录并获得fundService#depositFund
的结果。
List<MessageHistory> list = exchange.getProperty(Exchange.MESSAGE_HISTORY, List.class);
此外,您还需要调整MessageHistoryFactory
才能访问邮件+正文:
camelContext.getMessageHistoryFactory().setCopyMessage(true);