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 run开发者_StackOverflow社区ning transactions as usual?
(This is a follow up of How to stop message processing before undeploying?).
Given
- JBoss 4.2.3 with JBoss Messaging
- a Message Driven Bean according to EJB 2.0
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. - 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.
- I could stop the queue, but than I have to handle
NameNotFoundException
s within the producers.
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.
So even the queue is still moving, but unless u unset stopDelivery, the content of the queue is kind of freeze
精彩评论