【发布时间】:2014-03-12 18:11:45
【问题描述】:
我有一个 Camel 路由,可以将消息从队列中取出,将其发送到 bean 进行处理,然后将消息重新放入另一个队列中。
我正在尝试消除第二个队列中的“重复消息”。在将消息发送到第二个队列之前,Camel 是否有任何端点、处理器、EIP 等我可以配置为在途中对消息进行重复数据删除?
例子:
<route id="myRoute">
<from uri="{{queue-1-uri}}" />
<to uri="bean:myBean?method=process" />
<!-- How to dedupe right here??? -->
<to uri="{{queue-2-uri}}" />
</route>
更新:可能是这样的:
<route id="myRoute">
<from uri="{{queue-1-uri}}" />
<to uri="bean:myBean?method=process" />
<filter>
<method>what goes here???</method>
<to uri="{{queue-2-uri}}" />
</filter>
</route>
根据 Ralf 的建议,我可以在 <method></method> 中引用一个 bean,然后使用缓存将消息保存在内存中。
假设这个新 bean 被称为 FilterBean,它有一个 dedupe() 方法:我如何在 Spring XML 中连接它,以及 bean 需要实现哪些类/接口从路线内部调用?
【问题讨论】:
-
您可以使用支持分布式部署的缓存(如 EHCache 或 memcached)作为Message Filter 的后端服务。
-
感谢@Ralf (+1) - 请查看我的更新。关于我需要如何为
FilterBean实现什么 API/接口以及如何在 Spring XML 中连接它的任何想法?再次感谢!
标签: java apache-camel esb integration-patterns