java ActiveMQ 消费者挂起
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10017721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ActiveMQ Consumer Hangs
提问by Derek
I have an activeMQ broker using an SSL transport. I have about 10 consumers that are using the broker. I am using camel to configure my routes.
我有一个使用 SSL 传输的 activeMQ 代理。我有大约 10 个使用代理的消费者。我正在使用骆驼来配置我的路线。
Every so often, it hangs up and will not consume new messages, even if I restart the consumers, even though there are messages pending in the queues.
每隔一段时间,它就会挂断并且不会消耗新消息,即使我重新启动消费者,即使队列中有待处理的消息。
I started trying to isolate where this was happening by stepping through my consumers one at a time trying to replicate the problem. I finally got to a consumer that I could re-create the problem on. It will hang after a period of time, however, if I go to the active MQ admin console and try to view messages in the queue, it will start running again. I think that Jetty is causing a connection to happen to refresh the queue for the webpage, and thus unblocking some thread problem I am having. How should I debug this?
我开始尝试通过我的消费者一次一次地尝试复制问题来隔离发生这种情况的地方。我终于找到了一个可以重现问题的消费者。它会在一段时间后挂起,但是,如果我转到活动的 MQ 管理控制台并尝试查看队列中的消息,它将再次开始运行。我认为 Jetty 导致连接发生刷新网页的队列,从而解除我遇到的一些线程问题。我应该如何调试这个?
Thanks
谢谢
采纳答案by Derek
A colleague of mine stumbled onto something interesting, and I just found an explanation on the internet: http://activemq.2283324.n4.nabble.com/Consumer-is-not-able-to-pick-messages-from-queue-td2531722.html
我的一个同事偶然发现了一些有趣的东西,我刚刚在互联网上找到了一个解释:http: //activemq.2283324.n4.nabble.com/Consumer-is-not-able-to-pick-messages-from-queue -td2531722.html
Apparently there is a page size that can get filled when you have a selector and all the messages are in the same queue. This was happening for us - I hadn't started the consumer, so I ended up with a full page of messages with selectors for a different consumer, and this was causing my running consumer to not get any additional work sent to it.
显然,当您有一个选择器并且所有消息都在同一个队列中时,可以填充页面大小。这发生在我们身上 - 我还没有启动消费者,所以我最终得到了一整页带有选择器的消息,用于不同的消费者,这导致我正在运行的消费者没有收到任何额外的工作发送给它。
回答by Ben ODay
try setting the queue prefetch to 1 to promote better distribution across consumers and reduce 'stuck' messages on specific consumers
尝试将队列预取设置为 1 以促进更好的跨消费者分发并减少特定消费者上的“卡住”消息
see http://activemq.apache.org/what-is-the-prefetch-limit-for.html
见http://activemq.apache.org/what-is-the-prefetch-limit-for.html
回答by Denise
Too late for you, but I had the same problem and the problem was that I was trying to add things to the queue using the same connection I was using to take things off of the queue.
对你来说太晚了,但我遇到了同样的问题,问题是我试图使用我用来从队列中取出东西的相同连接将东西添加到队列中。
Once I separated them (two completely different contexts, one for producing and the other for consuming), the problem resolved itself.
一旦我将它们分开(两个完全不同的上下文,一个用于生产,另一个用于消费),问题就自行解决了。