JMS 消息在生产者连接关闭之前不会被消耗:-(

发布于 2024-12-10 11:34:58 字数 484 浏览 0 评论 0原文

我对 JMS 比较陌生,在实现我的第一个实际应用程序时遇到了一个奇怪的问题。我迫切需要任何帮助或建议。

背景:我使用 AtiveMQ (java) 作为具有非事务性、非持久性队列的消息代理。

设计:我有一个基于单个队列的直接生产者/消费者系统。许多节点(当前为 2 个)将消息放入队列或从队列中消费。选择器用于过滤节点接收哪些消息。

问题:生产者成功地将其项目放入队列(我已经使用网络界面验证了它们在那里),但是消费者仍然被阻止并且不读取它们。只有当我关闭生产者中的 JMS 连接时,消费者才会开始工作并按预期消费消息。

这种行为对我来说似乎很奇怪,当然你不应该完全挂断生产者连接才能让消费者能够从队列中读取数据。我一定在某个地方犯了一个错误(可能是在会话中),但目前可能出错的事情数量很大,我不知道什么会导致这种行为。

任何有关解决方案、问题原因或如何继续调试的提示将不胜感激。

感谢您抽出时间,

PS如果您需要任何其他信息,我很乐意提供

I am relatively new to JMS and have encountered a weird problem implementing my first real application. I'm desporate for any help or advice.

Background: I use AtiveMQ (java) as the message broker with non-transacted, non-persitent queues.

The Design: I have a straight forward producer/consumer system based around a single queue. A number of nodes(currently 2) place messages onto/ consume from the queue. Selectors are used to filter which messages a node recieves.

The Problem: The producer succesfully places its items on to the queue (i have verified they are there using the web interface) however the consumers remain blocked and do not read them. Only when i close the JMS connection in the producer do the consumers jump into life and consume the messages as expected.

This bevaior seems very weird to me, surely you shouldnt have to completely hang up the producer connection for the consumers to be able to read from the queue. I must have made a mistake somewhere(possibly with sessions) but the at the moment the number of things that could be wrong is to large and i have no idea what would cause this behaviour.

Any hints as to a solution, the cause of the problem or just how to continue debugging would be greatly appreciated.

Thanks for your time,

P.S If you requrie any additional information i am happy to provide it

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个少女永远怀春 2024-12-17 11:34:58

没有看到代码很难说,但听起来生产者已经进行了交易。您不必为了让消费者接收消息而关闭生产者,但事务生产者在您调用 commit 之前不会向其发送消息。其他需要检查的事情是连接是否已启动。此外,如果您有许多消费者,您应该查看预取设置,以确保一个消费者不会占用所有消息,可能需要将预取设置为 1,但如果不进一步深入了解您的用例,就很难说。

Hard to say without seeing the code, but it sounds like the producer is transacted. You should not have to close the producer in order for the consumers to receive a message but a transacted producer won't send it messages until you call commit. Other things to check is that the connection has been started. Also if you have many consumers you should look at the prefetch setting to ensure that one consumer doesn't hog all the messages, setting to prefetch of 1 might be needed, but hard to say without further insight into your use case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文