2013-07-11 3 views
0

수신자 목록 라우터와의 스프링 통합에서 어떻게 병렬 처리를 수행 할 수 있습니까?스프링 통합 - recipientlistrouter - 병렬 처리

목표는 라우터가 콘텐츠 기반이어야하며 멀티 캐스트처럼 병렬 처리로 다양한 채널에 메시지를 보내야한다는 것입니다. 난 당신을 낙타 스프링 통합 낙타에서 멀티 캐스트를 시도했지만 뭔가 수수가

감사

답변

0

나는 다음과 같이 스프링 통합의 RecipientListRouter을 확장하여 요구 사항의 비슷한 종류의 달성 :

public class CententBasedRecipientListRouter extends RecipientListRouter { 
    @Override 
    protected void handleMessageInternal(final Message<?> message) { 
     ...... 
    } 
} 

가 재정의 된 메서드에서, 당신은 당신의 요구 사항에 따라 사용자 정의 된 컨텐츠 기반 라우팅 로직을 구현할 수 있습니다.

<bean id="customRecipientListRouter" class="CententBasedRecipientListRouter"> 
    <property name="channels"> 
    <list> 
     <ref bean="parallelProcessingChannel1"/> 
     <ref bean="parallelProcessingChannel2"/> 
     <ref bean="parallelProcessingChannel3"/> 
    </list> 
    </property> 
</bean> 

<int:router ref="customRecipientListRouter" 
      input-channel="routingChannel" 
      default-output-channel="errorChannel" /> 

병렬 처리를 달성하기 위하여, 당신이 태스크 실행 프로그램 채널을 가질 수있는 다음과 같다 : 또한

<int:channel id="parallelProcessingChannel1"> 
    <int:dispatcher task-executor="threadPoolExecutor"/> 
</int:channel> 
1

내가 바로 질문을 이해 해요 경우를 할 경우 도와주세요

을 기반으로 콘텐츠를 구성 할 수 그냥 구독 채널을 라우터의 출력 채널로 게시해야합니다. 라우터는 내용을 기반으로 올바른 pubsub 채널로 메시지를 보내고 출력 채널 작업 실행자가 다중 스레드를 갖도록 구성된 경우 해당 채널에 가입 한 모든 처리기가 병렬로 실행됩니다.

<int:publish-subscribe-channel id="channel1" task-executor="someExecutor"/> 
<int:publish-subscribe-channel id="channel2" task-executor="someExecutor"/> 

<int:recipient-list-router id="customRouter" input-channel="routingChannel"> 
    <int:recipient channel="channel1" selector-expression="payload.equals('foo')"/> 
    <int:recipient channel="channel2" selector-expression="headers.containsKey('bar')"/> 
</int:recipient-list-router> 

위의 수신자 목록 라우터 구성은 Spring Integration 참조 설명서 5.1 절에서 복사됩니다.

+0

대신 publish- < '의 다음

이 맞춤 라우터

를 구성 할 수있다 subscribe-channel />'''자식 요소와 함께 ''을 사용할 수 있습니다. 두 경우 모두 라우터를 호출하는 스레드가 채널에 보내고 메시지는 실행 프로그램의 스레드 중 하나에서 전달됩니다. –