Announcement Announcement Module
Collapse
No announcement yet.
Correct usage of DefaultMessageListenerContainer.stop(Runnable callback) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Correct usage of DefaultMessageListenerContainer.stop(Runnable callback)

    I am currently using DefaultMessageListenerContainer and would like to stop the listener when certain exceptions are detected etc. e.g. some resource is unavailable. The stop method that takes a callback looks like just the ticket for my use case but I am having some difficulty using it. My Runnable seems to never be invoked. For instance if I have:

    Code:
    #Component("messageListenerController")
    public class MessageListenerController {
    
        #Resource
        private DefaultMessageListenerContainer jmsContainer;
    
        public void stop() {
            this.jmsContainer.stop(new Runnable() {
                public void run() {
                    System.err.println("--- Test ----");
                }
            });
        }
    }
    I never see the execution of the Runnable.

    Looking at the DefaultMessageListenerContainer thread(s) through jconsole seems to show they are waiting in "waitWhileNotRunning".


    Code:
    Stack trace: 
    java.lang.Object.wait(Native Method)
    java.lang.Object.wait(Object.java:474)
    org.springframework.jms.listener.AbstractJmsListeningContainer.waitWhileNotRunning(AbstractJmsListeningContainer.java:344)
    org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:866)
    java.lang.Thread.run(Thread.java:613)
    Is this an appropriate use of this method? I would like to have my runnable be able to be notified when the listener is stopped, verify resources are available, and bring the listener(s) back up with start. Any help is appreciated.

  • #2
    If it is helpful then here is the link to a new jira issue I just discovered that also describes this issue:

    jira.springframework.org/browse/SPR-5198

    Comment

    Working...
    X