ApacheCamel:pollEnrich不调用动态URI
创始人
2024-09-05 15:00:37
0

如果使用的URI是动态的,使用pollEnrich会出现以下问题:

  1. pollEnrich只使用初始URI进行轮询,而不使用替换的动态URI
  2. pollEnrich返回的Exchange不包含任何消息

为了解决这个问题,可以使用Recipient List EIP来代替pollEnrich。

Recipient List EIP可以动态选择要发送消息的路由,并将任何响应合并回原始Exchange。

以下是使用Recipient List EIP替换pollEnrich的示例代码:

from("direct:start") .recipientList().method(MyDynamicRecipientList.class) .parallelProcessing() .setHeader("originalMessage", simple("${body}")) .aggregate(new MyAggregationStrategy()) .completionSize(2) .completionTimeout(1000) .log("${header.originalMessage} + ' enriched with ' + ${body}") .to("direct:end");

public class MyDynamicRecipientList { public List getRecipients(@Header("myHeader") String myHeaderValue) { // Compute a dynamic URI based on the value of myHeader String dynamicURI = "ftp://myserver/" + myHeaderValue;

// Return a List containing the dynamic URI
return Collections.singletonList(dynamicURI);

} }

public class MyAggregationStrategy implements AggregationStrategy { public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { // Merge the new message into the original message String enrichedMessage = oldExchange.getIn().getBody(String.class) + " + " + newExchange.getIn().getBody(String.class);

// Set the new message as the body of the original Exchange
oldExchange.getIn().setBody(enrichedMessage);

return oldExchange;

} }

相关内容

热门资讯

透视数据!wepoker透视功... 透视数据!wepoker透视功能下载,we-poker正规吗(透视)一贯有挂(线上教程);1、打开软...
透视智能ai!fishpoke... 透视智能ai!fishpoker透视底牌,哈糖大菠萝万能挂,确实真的是有挂(攻略教程);1、下载好哈...
透视透视挂!悦扑克脚本,拱趴大... 透视透视挂!悦扑克脚本,拱趴大菠萝作弊方法(透视)固有真的是有挂(揭秘攻略)1、进入游戏-大厅左侧-...
透视规律!智星德州插件2024... 透视规律!智星德州插件2024最新版,德州真人透视脚本,都是真的有挂(AI教程)1、智星德州插件20...
透视线上!wpk俱乐部有没有辅... 透视线上!wpk俱乐部有没有辅助,aapoker怎么拿好牌(透视)都是有挂(透牌教程)wpk俱乐部有...
透视最新!newpoker脚本... 透视最新!newpoker脚本,pokemmo脚本,切实是有挂(揭秘教程);进入游戏-大厅左侧-新手...
透视挂!xpoker透视辅助,... 透视挂!xpoker透视辅助,德普软件(透视)真是有挂(玩家教程);1、用户打开应用后不用登录就可以...
透视科技!德州私人局怎么透视,... 透视科技!德州私人局怎么透视,pokermaster修改器,一贯真的有挂(2025新版技巧);1、下...
透视安卓版!wepoker祈福... 透视安卓版!wepoker祈福有用吗,xpoker辅助助手(透视)往昔有挂(新版2025教程)1、完...
透视透视挂!哈糖大菠萝辅助器,... 透视透视挂!哈糖大菠萝辅助器,pokemomo辅助工具,本来存在有挂(2025教程);该软件可以轻松...