gpt4 book ai didi

java - Camel 习惯用法根据消息正文中的值动态路由

转载 作者:行者123 更新时间:2023-11-30 04:59:09 25 4
gpt4 key购买 nike

假设您有这样的路线:

from("direct:start").to("http://some.endpoint/accounts/");

其中通过 direct:start 传递的消息是 XML:

<payload>
<account id="1">Bob</account>
</payload>

提取帐户的 id 并将其附加到 to 端点以便将此消息发送到 http://some.endpoint 的惯用方法是什么/accounts/1

最佳答案

您可以使用recipient list模式来创建基于 Exchange 数据的动态端点。

from("direct:start")
.recipientList(constant("http://some.endpoint/accounts/")
.append(XPathBuilder.xpath("/payload/account/@id", String.class)));

关于java - Camel 习惯用法根据消息正文中的值动态路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7519869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com