spring-integration 发送给订阅者时丢失 headers
spring-integration is losing headers when sent to a subscriber
我正在使用 spring-integration 和 hornetQ。问题是我在消息(方法)中放置了自定义 header,但是当它到达订阅者时,header 不再可用。我有某种配置 属性 我需要设置以保留 headers?
一个应用程序收到消息(我可以在控制台日志中看到 Method
header,所以我知道它实际上收到了正确的消息)。它基本上只是将消息路由到出站 queue 以便客户可以订阅它(如果有更简洁的方法,请告诉我)
<int:channel id="partsChannel" />
<int-jms:message-driven-channel-adapter
id="jmsPartsInbound"
acknowledge="transacted"
destination-name="parts.in"
channel="partsChannel"
connection-factory="jmsConnectionFactory"
/> <!-- error-channel="partsInboundFailedChannel" -->
<int-jms:outbound-channel-adapter
id="jmsPartsOutbound"
destination-name="parts.out"
channel="partsChannel"
connection-factory="jmsConnectionFactory"
pub-sub-domain="true"
>
<int-jms:request-handler-advice-chain>
<int:retry-advice max-attempts="3">
<int:exponential-back-off initial="2000" multiplier="2" />
</int:retry-advice>
</int-jms:request-handler-advice-chain>
</int-jms:outbound-channel-adapter>
应用程序这样订阅:
<int:channel id="partsInboundChannel" />
<int-jms:message-driven-channel-adapter
id="jmsPartsInbound"
acknowledge="transacted"
destination-name="parts.out"
channel="partsInboundChannel"
pub-sub-domain="true"
connection-factory="jmsConnectionFactory"/>
这是在订阅者中获取消息的部分。
@ServiceActivator(inputChannel = "partsInboundChannel")
public void processPart(final Message message) {
...message.getHeaders does not contain the "Method" header
}
你的问题不在 DefaultJmsHeaderMapper.fromHeaders
:
if (value != null && SUPPORTED_PROPERTY_TYPES.contains(value.getClass())) {
try {
String propertyName = this.fromHeaderName(headerName);
jmsMessage.setObjectProperty(propertyName, value);
}
其中SUPPORTED_PROPERTY_TYPES
是:
private static List<Class<?>> SUPPORTED_PROPERTY_TYPES = Arrays.asList(new Class<?>[] {
Boolean.class, Byte.class, Double.class, Float.class, Integer.class, Long.class, Short.class, String.class });
所以,如果你的 method
真的是 Method
类型,它将被跳过。
考虑改用其 name
。
我正在使用 spring-integration 和 hornetQ。问题是我在消息(方法)中放置了自定义 header,但是当它到达订阅者时,header 不再可用。我有某种配置 属性 我需要设置以保留 headers?
一个应用程序收到消息(我可以在控制台日志中看到 Method
header,所以我知道它实际上收到了正确的消息)。它基本上只是将消息路由到出站 queue 以便客户可以订阅它(如果有更简洁的方法,请告诉我)
<int:channel id="partsChannel" />
<int-jms:message-driven-channel-adapter
id="jmsPartsInbound"
acknowledge="transacted"
destination-name="parts.in"
channel="partsChannel"
connection-factory="jmsConnectionFactory"
/> <!-- error-channel="partsInboundFailedChannel" -->
<int-jms:outbound-channel-adapter
id="jmsPartsOutbound"
destination-name="parts.out"
channel="partsChannel"
connection-factory="jmsConnectionFactory"
pub-sub-domain="true"
>
<int-jms:request-handler-advice-chain>
<int:retry-advice max-attempts="3">
<int:exponential-back-off initial="2000" multiplier="2" />
</int:retry-advice>
</int-jms:request-handler-advice-chain>
</int-jms:outbound-channel-adapter>
应用程序这样订阅:
<int:channel id="partsInboundChannel" />
<int-jms:message-driven-channel-adapter
id="jmsPartsInbound"
acknowledge="transacted"
destination-name="parts.out"
channel="partsInboundChannel"
pub-sub-domain="true"
connection-factory="jmsConnectionFactory"/>
这是在订阅者中获取消息的部分。
@ServiceActivator(inputChannel = "partsInboundChannel")
public void processPart(final Message message) {
...message.getHeaders does not contain the "Method" header
}
你的问题不在 DefaultJmsHeaderMapper.fromHeaders
:
if (value != null && SUPPORTED_PROPERTY_TYPES.contains(value.getClass())) {
try {
String propertyName = this.fromHeaderName(headerName);
jmsMessage.setObjectProperty(propertyName, value);
}
其中SUPPORTED_PROPERTY_TYPES
是:
private static List<Class<?>> SUPPORTED_PROPERTY_TYPES = Arrays.asList(new Class<?>[] {
Boolean.class, Byte.class, Double.class, Float.class, Integer.class, Long.class, Short.class, String.class });
所以,如果你的 method
真的是 Method
类型,它将被跳过。
考虑改用其 name
。