2013-11-02 4 views
1

저는 스프링 통합 및 스프링 통합 AMQP를 처음 사용했습니다.스프링 통합 - 헤더 손실

<bean id="enricher" class="soft.Enricher"/> 

<amqp:inbound-channel-adapter queue-names="QUEUE1" channel="amqpInboundChannel"/> 

<int:channel id="amqpInboundChannel"> 
    <int:interceptors> 
     <int:wire-tap channel="logger"/> 
    </int:interceptors> 
</int:channel> 

<int:header-enricher input-channel="amqpInboundChannel" output-channel="routingChannel"> 
     <int:header name="store" value="sj" /> 
</int:header-enricher> 

<int:channel id="routingChannel" /> 

<int:header-value-router input-channel="routingChannel" header-name="store"> 
    <int:mapping value="sj" channel="channelSJ" /> 
    <int:mapping value="jy" channel="channelJY" /> 
</int:header-value-router> 

<amqp:outbound-channel-adapter channel="channelSJ" exchange-name="ex_store" routing-key="sj" amqp-template="rabbitTemplate"/> 
<amqp:outbound-channel-adapter channel="channelJY" exchange-name="ex_store" routing-key="jy" amqp-template="rabbitTemplate"/> 

<int:channel id="channelSJ" /> 
<int:channel id="channelJY" /> 

<int:logging-channel-adapter id="logger" level="ERROR" /> 

셋업은 다음과 같다 :

나는 다음과 같은 코드가

My Setup

모든 제외하고 잘 작동하는 메시지가 인바운드에 의해 포착 될 때 헤더가 손실되는 - 채널 어댑터.

아웃 바운드 채널 어댑터를 사용하여 메시지를 교환기로 보낼 때 마찬가지로 "저장소"라고도 불리는 헤더가 손실됩니다.

Before

같은 메시지가 (어떤 헤더를 알 수 없음) 전체 과정을 돌보는 방법 이것은

:

이 메시지가 인바운드 채널 어댑터에 의해 선택되기 전에 찾고 어떻게

After

답변

7

나는 당신의 문제가 here을 설명 생각 :

,

"기본적으로 표준 AMQP 속성 (예 : contentType)은 Spring Integration MessageHeaders에 복사된다. AMQP MessageProperties 내의 사용자 정의 헤더는이 HeaderMapper의 'requestHeaderNames'및/또는 'replyHeaderNames'등록 정보를 통해 명시 적으로 식별되지 않는 한 AMQP 메시지로 또는 AMQP 메시지에서 복사되지 않습니다. 모든 사용자 정의 헤더를 복사해야하는 경우 단순히 와일드 카드 문자 ''를 사용합니다. * "

그래서 당신이 DefaultAmqpHeaderMapper의 사용자 정의 인스턴스를 정의하고 함께 inbound-channel-adapter를 구성해야합니다. here를 참조하십시오.

그것은 다음과 같이 보일 수

:.?

 <bean id="myHeaderMapper" class="org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper"> 
        <property name="requestHeaderNames" value="*"/> 
        <property name="replyHeaderNames" value="*"/> 
     </bean> 

     <amqp:inbound-channel-adapter queue-names="QUEUE1" channel="amqpInboundChannel" 
             header-mapper="myHeaderMapper"/> 
+0

당신은 그냥 기본적인 스프링 구성입니다 마법 아무것도 –

+0

을 코드 예제를 추가하지시겠습니까하지만 난 당신이 원하는에 근접해야 뭔가를 추가 – Vidya

+1

또한 매핑 할 수 있습니다.. -의뢰- adapapter의 headers = "*". –