What would be a nice and good way to temporarily disable a message listener? The problem I want to solve is:
- A JMS message is received by a message listener
- I get an error when trying to process the message.
- I wait for my system to get ready again to be able to process the message.
- Until my system is ready, I don't want any more messages, so...
- ...I want to disable the message listener.
- My system is ready for processing again.
- The failed message gets processed, and the JMS message gets acknowledged.
- Enable the message listener again.
Right now, I'm using Sun App Server. I disabled the message listener by setting it to null in the MessageConsumer, and enabled it again using setMessageListener(myOldMessageListener), but after this I don't get any more messages.