【发布时间】:2015-11-15 11:37:35
【问题描述】:
我正在尝试使用 SmartLifecycle stop 方法停止 message-driven-channel-adapter,但可能有 1/3 的时间会导致警告消息:
DefaultMessageListenerContainer - 由于侦听器容器同时停止而拒绝接收到的消息
检查 ActiveMQ 表明消息确实已丢失。
我正在使用JmsTemplate 让 ActiveMQ 与 Spring Integration 对话。我的豆子看起来像:
<bean id="Topic" class="org.apache.activemq.command.ActiveMQQueue">...</bean>
<bean id="archiveTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="defaultDestination" ref="Topic"></property>
...
</bean>
<si:channel id="InputChannel" />
<jms:message-driven-channel-adapter
id="archiveInboundAdapter" channel="InputChannel" destination="Topic" />
<si:service-activator id="archiveConsumerActivator"
input-channel="InputChannel" ref="consumer" method="onMessage" />
然后在我的代码中获取archiveInboundAdapter bean 并在其上调用stop()。
有什么想法吗?有没有更好的方法来停止接收消息?实际上,我正试图以有序的方式处理系统关闭(停止接收消息,停止处理这些消息的复杂线程系统,退出)。
【问题讨论】:
标签: activemq spring-integration