向已满的 JMS 队列发送消息
我正在编写一个将消息发送到 JMS 队列的 Java 代码。 我通过使用“QueueSender.send()”来做到这一点。
JMS 队列本身是 sonicMQ,但这不是重点。
我的问题是,有时 JMS 队列已满,并且尝试向队列发送消息的线程处于饥饿状态。
有没有办法让我在发送消息之前知道队列是否已满?在这种情况下,我更愿意在日志中打印异常。
顺便说一句,JMS 队列代码本身超出了我的能力范围。我只能更改客户端代码。
谢谢。
I am writing a Java code that sends messages to a JMS queue.
I am doing this by using "QueueSender.send()".
The JMS queue itsels is sonicMQ but that's beside the point.
My problem is that sometimes the JMS queue is full and the thread that tries to send messages to the queue is starved.
Is there a way for me to know if the queue is full before sending the message? In this case I would prefer to print an exception to the log.
By the way, the JMS queue code itself is out of my reach. I can only change only the client code.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 ConnectionFactory 中使用 Constants.ASYNC_DELIVERY_MODE_ENABLED 异步发送消息,
您可以使用 spring
请参阅更多详细信息
progress.message.jclient 类 ConnectionFactory
You can send the messages asynchronic to do so setAsynchronousDeliveryMode with Constants.ASYNC_DELIVERY_MODE_ENABLED in the ConnectionFactory
using spring
see more details in
progress.message.jclient Class ConnectionFactory
事实并非如此,如果我没记错的话,这个 QueueMaxSize 属性是 SonicMQ 特定的。
我对 Progress Sonic MQ 性能调整指南 7.5 关于 < code>QueueMaxSize 属性是这是正常的(也是想要的)行为:
现在,也许可以通过 JMX 客户端获取通知,但我不确定这在您的上下文中是否可行(请查看 Progress SonicMQ 管理编程指南 V7.5 如果您想进一步深入了解或联系支持人员)。但我真的不确定这是否有效。事实上,我不知道你想做的是否是一个好主意。
Not really, this
QueueMaxSize
property is SonicMQ specific if I'm not wrong.My understanding of the Progress Sonic MQ Performance Tuning Guide 7.5 about the
QueueMaxSize
Property is that this is the normal (and wanted) behavior:Now, it would be maybe possible to get a Notification with a JMX client but I'm not sure this is feasible in your context (have a look at the Progress SonicMQ Administrative Programming Guide V7.5 if you want to dig this further or contact the support). But I'm really not sure this would work. Actually, I don't know if what you want to do is a good idea.
您描述的行为是 SonicMQ 特定的,称为流量控制。在某些情况下,这是一个非常好的功能,但在其他情况下,这可能会导致整排系统出现问题。不幸的是,我还没有找到任何方法来改变基于队列的场景中的这种行为。
我可以想象处理此行为的唯一场景是使用 Managemnt API 或 JMX 客户端。一般有两种可能性:
但是:这只能通过专有的 SonicMQ API 实现,而无法通过标准 JMS 实现这一点。我会要求 SonicMQ 环境的管理员观察流量控制事件并做出适当的反应...
The behavoir you describe is SonicMQ specific, it is called Flow Control. In some scenarios this is a pretty good feature, in others this may cause a whole row of systems becoming problems. Unfortunately i haven' found any method to change this behaviour in queue based scenarios.
The only scenarios that i can imagine to handle this behavior is to use the Managemnt API or a JMX client. There are two general possibilities:
However: this is only possible with the proprietary SonicMQ API, you can not do this with Standard JMS. I would ask the administrators of the SonicMQ environment to watch the FLow Control events and react appropriately...