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;

} }

相关内容

热门资讯

技巧五分钟!wpk辅助插件微扑... 技巧五分钟!wpk辅助插件微扑克网页版辅助(原来真的有挂)-今日头条;1、微扑克网页版辅助系统规律教...
工具七分钟!微扑克到底有辅助器... 工具七分钟!微扑克到底有辅助器wepoke软件透明功能实现方法(总是真的有挂)-微博客户端;1、we...
检测八分钟!gg扑克发牌机制w... 检测八分钟!gg扑克发牌机制wepoke软件透明挂辅助(一般真的有挂)-百度知乎1、实时wepoke...
检测六分钟!德州ai能盈利po... 检测六分钟!德州ai能盈利pokerworld下载外挂(果真真的有挂)-知乎1)pokerworld...
挂8分钟!aapoker软件a... 挂8分钟!aapoker软件aapoker发牌规律(的确是有挂的)-微博客户端1、该软件可以轻松地帮...
插件7分钟!德州ai辅助器wo... 插件7分钟!德州ai辅助器wopoker苹果可以下载(一般真的有挂)-今日头条;1、打开软件启动之后...
胜率三分钟!wepoke有挂网... 胜率三分钟!wepoke有挂网上靠谱wpk透明挂(总是真的有挂)-今日头条;1、不需要AI权限,帮助...
软件五分钟!微扑克辅助软件wp... 软件五分钟!微扑克辅助软件wpk俱乐部有外挂(果真真的有挂)-微博客户端1)微扑克辅助软件辅助挂:进...
模拟器九分钟!pokermas... 模拟器九分钟!pokermaster是有外挂wpk有机器人(好像真的有挂)-哔哩哔哩pokermas...
最新款5分钟!德扑ai智能机器... 最新款5分钟!德扑ai智能机器人wepoke软件透明下载渠道(一直真的有挂)-微博客户端1、wepo...