链接地址http://quentinXXZ.iteye.com/blog/2126684
ActiveMq在stop操作,停止接收时,出现如下提示:
2014-09-23 20:26:23,233 WARN [ActiveMQ Session Task-1] (AbstractMessageListenerContainer.java:461) - Rejecting received message because of the listener container having been stopped in the meantime: ActiveMQTextMessage ....
我开始怀疑是否存在消息丢失。
经查询,做如下修改,将acceptMessageWhileStopping从false改为true就不再出现上述提示。对应的方法名为setAcceptMessagesWhileStop()
官方说明如下:
-
Set whether to accept received messages while the listener container in the process of stopping.
Default is "false", rejecting such messages through aborting the receive attempt. Switch this flag on to fully process such messages even in the stopping phase, with the drawback that even newly sent messages might still get processed (if coming in before all receive timeouts have expired).
NOTE: Aborting receive attempts for such incoming messages might lead to the provider's retry count decreasing for the affected messages. If you have a high number of concurrent consumers, make sure that the number of retries is higher than the number of consumers, to be on the safe side for all potential stopping scenarios.
-
上述说明,仍无法确认是否真正的存在消息丢失。
后来做了下实验,将只开发送端,接收端不开,在Broker持久化一定量消息,再关闭发送端。acceptMessageWhileStopping设为false。启动接收端,并在其统计接收count,再做stop,出现上述的warn信息。再与activemq监控页面的count数据进行加减,对比,发现确实存在消息丢现象(当然也有可能跟具体的环境与代码有关)。
本文详细分析了在使用ActiveMQ过程中遇到的停止接收消息时出现的警告信息,并通过实验验证了消息可能存在的丢失情况。讨论了如何通过设置配置参数解决该问题,并提供了确认消息丢失与否的实验方法。

2万+

被折叠的 条评论
为什么被折叠?



