当出站适配器无法打开目标队列时,消息将从源丢失

时间:2014-04-12 15:12:10

标签: jms spring-integration spring-jms spring-io

我有入站邮件侦听器适配器,当出站适配器无法打开目标队列时,邮件会从源队列中丢失。我正在使用spring-io进行jms队列消息传输。

如何在邮件到达目标队列后提交传输,或者保留在源队列中?

2 个答案:

答案 0 :(得分:0)

acknowledge="transacted"上设置message-driven-channel-adapter

答案 1 :(得分:0)

这只是从消费者到生产者的交易传播问题。您可以通过执行以下附加配置轻松解决此问题。

如果您使用DefaultMessageListenerContainer,强烈建议将sessionTransacted设置为true或指定外部事务管理器。

如果您没有配置消息侦听器容器,而是使用message-driven-channel-adapter,则需要将其acknowledge属性设置为transacted

要配置出站适配器以参与事务,您需要按如下方式配置JmsTemplate并将其sessionTransacted属性设置为true

<bean id="outboundJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="outboundCF" />
    <property name="defaultDestination" ref="outboundDestination" />
    <property name="sessionTransacted" value="true" />
</bean>
<int-jms:outbound-channel-adapter channel="jmsOutChannel" jms-template="outboundJmsTemplate" />

希望它能解决你的问题。