简体   繁体   English

如何停止将消息传递到消息驱动Bean?

[英]How to stop message delivery to a Message Driven Bean?

Question

Is it possible to stop a Message Driven Bean (programmatically), so that it doesn't consume new messages, but processes running transactions as usual? 是否可以(以编程方式)停止消息驱动Bean,以便它不消耗新消息,而是像往常一样处理正在运行的事务?

(This is a follow up of How to stop message processing before undeploying? ). (这是如何在取消部署之前停止消息处理的后续操作 )。

Given 特定

  • JBoss 4.2.3 with JBoss Messaging 具有JBoss消息传递功能的JBoss 4.2.3
  • a Message Driven Bean according to EJB 2.0 根据EJB 2.0的消息驱动Bean

Failed Attempts 尝试失败

  • I'd like to use the MBean method stopDelivery , but sadly it closes transactions immediately (see bug #EJBTHREE-1870 ) and thereby causes a lot of exceptions. 我想使用MBean方法stopDelivery ,但可悲的是它立即关闭了事务(请参见Bug #EJBTHREE-1870 ),从而导致许多异常。
  • I tried to reduce the max pool size to 0 in the JMX console, but the number of active sessions isn't affected at all. 我试图在JMX控制台中将最大池大小减小为0,但是活动会话的数量完全不受影响。
  • I could stop the queue, but than I have to handle NameNotFoundException s within the producers. 我可以停止队列,但是必须在生产者中处理NameNotFoundException

Well here is a though, almost everything can be achieved with a wrapper, You can let MDB keep receive message, but introduce a Boolean stopDelivery, while before message going to be processed by business logic, check if stopDelivery is set to true, if so, resend the message back to your queue where it is came from. 好了,尽管这几乎可以用包装器完成。您可以让MDB保持接收消息,但是引入一个布尔值stopDelivery,而在业务逻辑要处理消息之前,请检查stopDelivery是否设置为true,如果是这样,将邮件重新发送回您的队列。

So even the queue is still moving, but unless u unset stopDelivery, the content of the queue is kind of freeze 因此,即使队列仍在移动,但是除非您未设置stopDelivery,否则队列的内容会冻结

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

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