首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Camel EIP过滤副本

Camel EIP过滤副本
EN

Stack Overflow用户
提问于 2014-02-13 17:36:45
回答 1查看 3K关注 0票数 1

我有一个Camel路由,它将消息从队列中排掉,发送到bean进行处理,然后将消息排回另一个队列。

我正在努力消除第二个队列中的“重复消息”。骆驼有什么端点,处理器,EIP,等等,我可以配置,在他们被发送到第二队列之前,在途中丢弃消息吗?

示例:

代码语言:javascript
复制
<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>

更新:可能是这样的:

代码语言:javascript
复制
<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>

根据拉尔夫的建议,我可以在<method></method>中引用一个bean,然后使用缓存将消息保存在内存中。

FilterBean表示,这个新bean名为 dedupe() ,它上有一个方法:如何在Spring中连接它,以及需要实现哪些类/接口从路由内部调用?

EN

回答 1

Stack Overflow用户

发布于 2014-02-13 22:18:15

我想你是在寻找骆驼提供的Idempotent Consumer。有不同的方法取决于您的需要,如内存,JDBCHazelcast.我不太确定它是否对你有用,因为你在消费者之后使用bean,但是值得一试。Camel网站的简单例子如下:

代码语言:javascript
复制
<!-- repository for the idempotent consumer -->
<bean id="myRepo" class="org.apache.camel.processor.idempotent.MemoryIdempotentRepository"/>

<camelContext xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="direct:start"/>
        <idempotentConsumer messageIdRepositoryRef="myRepo">
            <!-- use the messageId header as key for identifying duplicate messages -->
            <header>messageId</header>
            <!-- if not a duplicate send it to this mock endpoint -->
            <to uri="mock:result"/>
        </idempotentConsumer>
    </route>
</camelContext>

您可以在这里找到更多信息:幂等消费者

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21761470

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档