Java 用于过滤重复项的驼峰EIP

Java 用于过滤重复项的驼峰EIP,java,apache-camel,esb,integration-patterns,Java,Apache Camel,Esb,Integration Patterns,我有一个驼峰路由,它将消息从队列中取出,发送给bean进行处理,然后将消息重新排回到另一个队列中 我试图消除第二个队列上的“重复消息”。Camel是否有任何端点、处理器、EIP等,我可以将其配置为在发送到第二个队列之前在路由中消除消息的重复 例如: <route id="myRoute"> <from uri="{{queue-1-uri}}" /> <to uri="bean:myBean?method=process" /> <

我有一个驼峰路由,它将消息从队列中取出,发送给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>

这里有什么???
根据拉尔夫的建议,我可以引用
中的一个bean,然后使用缓存将消息保存在内存中


假设这个新bean被称为
FilterBean
,它有一个
Duplicate()
方法:如何在SpringXML中连接它,以及bean需要实现哪些类/接口才能从路由内部调用?
我想您正在寻找Camel提供的
幂等消费者。根据您的需要,有不同的方法,如内存、
JDBC
Hazelcast
。。。我不确定它是否适合你,因为你是在消费者之后使用
bean
,但值得一试。Camel网站的简单示例如下:

<!-- 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>

消息ID

您可以在此处找到更多信息:

您可以使用像EHCache或memcached这样支持分布式部署的缓存作为a的后端服务。谢谢@Ralf(+1)-请查看我的更新。关于我需要为
FilterBean
实现什么样的API/接口,以及如何在SpringXML中连接它,有什么想法吗?再次感谢!