1

メッセージをキューからデキューし、それを処理のために Bean に送信してから、メッセージを別のキューにエンキューする Camel ルートがあります。

2 番目のキューで「重複メッセージ」を排除しようとしています。Camel には、2 番目のキューに送信される前にメッセージを重複排除するように構成できるエンドポイント、プロセッサ、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 の提案に従って、内部の Bean を参照し<method></method>、キャッシュを使用してメッセージをメモリに保持することができました。

この新しい Bean が呼び出されFilterBean、そのdedupe()上にメソッドがあったとします。どうすればそれを Spring XML に結び付けることができますか? また、Bean がルート内から呼び出されるために実装する必要があるクラス/インターフェースは何ですか?

4

1 に答える 1

3

Idempotent ConsumerCamel が提供する を探していると思います。JDBCメモリ、などのニーズに応じてさまざまなアプローチがありますHazelcast...消費者の後に使用しているので、それがうまくいくかどうかはわかりませんがbean、試してみる価値があります。Camel Web サイトの簡単な例は次のとおりです。

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

ここで詳細情報を見つけることができます:べき等消費者

于 2014-02-13T22:18:15.327 に答える