【问题标题】:Trying to stop a message-driven-channel-adapter but droppping a message试图停止消息驱动的通道适配器但丢弃消息
【发布时间】: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


    【解决方案1】:

    设置acknowledge="transacted",以便进行中的消息回滚到队列中。

    【讨论】:

      猜你喜欢
      • 2019-10-19
      • 2017-04-29
      • 2014-01-23
      • 2011-04-29
      • 1970-01-01
      • 1970-01-01
      • 2015-09-10
      • 1970-01-01
      • 2021-03-20
      相关资源
      最近更新 更多