Uploaded image for project: 'Qpid JMS'
  1. Qpid JMS
  2. QPIDJMS-244

Connection close does not wait for acknowledgement of in-flight message delivery with asyncronous auto-ack MessageConsumer

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.1.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.10.0, 0.11.0, 0.11.1, 0.20.0
    • 0.21.0
    • qpid-jms-client
    • None

    Description

      The jms client can fail to acknowledge the message (with auto-ack delivery mode) which is in a process of delivery with MessageListener when Connection#close() is called from main application thread.

      The exception like the one below is delivered into ExceptionListener:
      Connection ExceptionListener fired, exiting.

      javax.jms.IllegalStateException: The MessageConsumer is closed
          at org.apache.qpid.jms.JmsMessageConsumer.checkClosed(JmsMessageConsumer.java:328)
          at org.apache.qpid.jms.JmsMessageConsumer.doAckConsumed(JmsMessageConsumer.java:372)
          at org.apache.qpid.jms.JmsMessageConsumer.access$600(JmsMessageConsumer.java:52)
          at org.apache.qpid.jms.JmsMessageConsumer$MessageDeliverTask.run(JmsMessageConsumer.java:679)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at java.lang.Thread.run(Thread.java:745)

      Such behavior could be considered JMS spec compliment, as the JMS specification v1.1 states in "4.3.5 Closing a Connection" :

      If one or more of the connection’s session’s message listeners is processing a message at the point when connection close is invoked, all the facilities of the connection and its sessions must remain available to those listeners until they return control to the JMS provider."

      Thus, it seems that closing of the connection is allowed without sending the acknowledgment (and waiting for response), as acknowledgment is sent after the control is returned to JMS provider.

      However, from practical point of view, such behavior might not be desirable, as it would cause duplicate message deliveries for those messages not being acknowledged on close. I would expect from the JMS client to acknowledge the in-flight auto-ack message deliveries with MessageConsume#onMessage before the connection close.

      Attachments

        Activity

          People

            tabish Timothy A. Bish
            orudyy Alex Rudyy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: