2014-02-13 3 views
1

나는 큐에서 메시지를 큐에서 빼내어 처리를 위해 콩으로 보내고 다른 큐에 다시 큐에 대기시키는 Camel 라우트를 가지고있다.카멜 EIP로 중복 필터

두 번째 큐에서 "중복 메시지"를 제거하려고합니다. 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> 

, 나는 다음 다음에 메시지를 유지하기 위해 캐시를 사용 <method></method> 내부 빈을 참조 할 수있다 기억. 나는 콩이 경로 내부에서 호출 할 구현해야하는 일의 클래스/인터페이스는 Spring XML에 그것을 와이어, 그리고 어떻게 :

이 새로운 빈이 FilterBean라고하고 그것에 dedupe() 방법을 있었다 말 ?

+1

당신은 [메시지 필터]에 백엔드 서비스로 배포를 분산 지원 EHCache는 나 memcached와 같은 캐시를 사용할 수를 (http://camel.apache.org/message-filter.html). – Ralf

+0

Thanks @Ralf (+1) - 내 업데이트를 참조하십시오. 'FilterBean'을 구현하기 위해 어떤 API/인터페이스를 구현해야하는지, 그리고 Spring XML에서 어떻게 연결해야하는지에 대한 아이디어가 있습니까? 다시 한 번 감사드립니다! – AdjustingForInflation

답변

3

나는 Camel이 제공하는 Idempotent Consumer을 찾고 있다고 생각합니다. 메모리, JDBC, Hazelcast과 같은 요구에 따라 다른 접근법이 있습니다 ... 소비자 후 bean을 사용하고 있기 때문에 실제로 작동하는지 잘 모르겠지만 시도해 볼 가치가 있습니다. 다음과 낙타의 웹 사이트에서 간단한 예입니다 : 당신은 여기에 대한 추가 정보를 찾을 수 있습니다

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

: Idempotent Consumer