簡體   English   中英

Apache Camel Rest - 如何將請求和響應從上一個端點發送到下一個端點

[英]Apache Camel Rest - How to send request and response from previous endpoint to next

我想實現一個駱駝 DSL 邏輯,例如,我有兩條路由,其中收到的第一條路由的請求應該與來自第一條路由的響應一起傳遞給第二條路由。 我如何實現這一目標?

        `.to("direct:validatePayload")
            .to("bean:fundService?method=depositFund(${exchange})")
            .to("bean:rparticipantService?method=notifyParticipant(${exchange})");`

在上面的代碼中,在驗證請求負載后,具有 Fund 主體的交易所作為請求傳遞給 depositFund。 在此之后,我想將請求傳遞給 notifyParticipant,這將結合來自 depositFund 的響應以及 depositFund 收到的請求。 我如何通過駱駝 DSL 代碼實現這一點。

查看消息歷史記錄: 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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM