[英]Spring Integration - header lost
我是Spring Integration和Spring Integration 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" />
設置如下:
一切正常,除了當inbound-channel-adapter收到一條消息時頭丟失。
同樣,當使用出站通道適配器將消息發送到交換機時,被稱為“存儲”的標頭也丟失。
這是一條消息在被inbound-channel-adapter接收之前的外觀:
這是在整個過程中查找相同消息的方式(注意沒有標題)
我覺得你的問題是描述在這里 :
“ 默認情況下,僅標准AMQP屬性(例如contentType)將與Spring Integration MessageHeaders相互復制。除非通過'requestHeaderNames'和/或明確標識,否則AMQP MessageProperty中的任何用戶定義的標頭都不會與AMQP消息復制或復制。此HeaderMapper的'replyHeaderNames'屬性。如果您需要復制所有用戶定義的標頭,只需使用通配符' '。*'
因此,您需要定義自己的DefaultAmqpHeaderMapper
的自定義實例,並使用它配置inbound-channel-adapter
。 看這里 。
它可能看起來像這樣:
<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"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.