2
我試圖用SmartLifecycle
stop
方法停止message-driven-channel-adapter
,但也許1/3的時間,這導致警告消息:企圖阻止消息驅動通道適配器但droppping消息
使用DefaultMessageListenerContainer - 拒絕,因爲聽者容器接收的消息已經停止在此期間
檢查的ActiveMQ表明消息真的已經丟失。
我正在使用一個JmsTemplate
來讓ActiveMQ與Spring集成交談。我的豆看起來像:
<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
豆並在其上調用stop()
。
任何想法?有沒有更好的方法來阻止接收消息?實際上,我只是試圖以有序的方式處理系統關閉(停止接收消息,停止處理這些消息的複雜線程系統,退出)。