简体   繁体   English

在生产者连接关闭之前不使用JMS消息:-(

[英]JMS Messages not consumed till producer connection close :-(

I am relatively new to JMS and have encountered a weird problem implementing my first real application. 我对JMS相对较新,在实现我的第一个实际应用程序时遇到了一个奇怪的问题。 I'm desporate for any help or advice. 我很乐意提供任何帮助或建议。

Background: I use AtiveMQ (java) as the message broker with non-transacted, non-persitent queues. 背景:我将AtiveMQ(java)用作具有非事务,非持久队列的消息代理。

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. 许多节点(当前为2个)将消息放入队列或从队列中使用。 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. 问题:生产者成功地将其项目放置到队列中(我已经使用Web界面验证了它们的存在),但是消费者仍然处于阻塞状态,并且不读取它们。 Only when i close the JMS connection in the producer do the consumers jump into life and consume the messages as expected. 只有当我关闭生产者中的JMS连接时,消费者才能进入生活并按预期使用消息。

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, 谢谢你的时间,

PS If you requrie any additional information i am happy to provide it PS:如果您需要任何其他信息,我很乐意提供

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. 您不必为了让使用者接收消息而关闭生产者,但是事务处理的生产者在您调用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. 同样,如果您有许多使用者,则应查看预取设置以确保一个使用者不会占用所有消息,可能需要将其设置为1,但是如果不进一步了解用例就很难说。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM