Announcement Announcement Module
Collapse
No announcement yet.
Graceful shutdown of JMS message listener? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Graceful shutdown of JMS message listener?

    Hi,
    We use spring JMS DefaultMessageListenerContainer within a tomcat 7 container.
    When the application is closed or Tomcat shutdown will there automatically be a graceful shutdown of the listener?
    With graceful I mean that the listener shall not accept any new JMS-messages and the ongoing handled messages
    should be allowed to continue until finished and then the listener shall close.
    /Gunnar

  • #2
    Yes.

    But, if the in-flight messages use other active components (that will also be stopped by the context), then some of those might fail.

    To avoid this problem you can explicitly invoke stop(Runnable callback) on the DMLC, in which case the passed-in callback will be informed (run) when all the threads have actually stopped.

    Comment


    • #3
      Hi Gary,
      Good to know.
      Our jmsListener stores data in a database with connections managed by spring. If the connection to the database is destroyed before the jms handler is ready then we have a problem. I assume that is what you mean, but I don't understand how calling stop with a runnable can solve that problem. Can you please elaborate on the subject?
      /Gunnar

      Comment


      • #4
        Well, my response was in your question to the application being closed, or the container stopped.

        In that case, the application context will stop all beans (any implementing Lifecycle) before destroying any. The normal stop() on the DMLC is asynch.

        What I mean is that you can programmatically call stop(Runnable) before stopping the application and wait for the callback before shutting down the context in the normal manner. You could do this in a number of ways - a secured web page, JMX, a Spring Integration <control-bus/> etc, etc.

        When the Runnable is called, you know it is safe to stop the application because all in-flight messages will have finished.

        Comment


        • #5
          Hi Gary,
          Thanks, now I understand!
          /Gunnar

          Comment

          Working...
          X