Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-7178

Auto-delete queue removed while it has consumers

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: JMS AMQP 0-x, Python Client
    • Labels:
      None

      Description

      We seem to have run into a bug where we create a queue with auto-delete=true from Python and then send to it using the JMS client. When the JMS MessageProducer is closed the queue is removed even if the Python client is still consuming from it.

      We first create the queue from Python (qpid-python 0.32, Python 2.7) and send a message to another queue "foo-bar" with the newly created auto-delete queue as the reply-to address. The connection and session is kept open until a response is received.

      A very cut down version of the Python code is below. The client will call create_queue, send_request and then await_response and in await_response we then (9 out of 10 times) get:

        File "client.py", line NN, in await_response
          receiver = self._session.receiver(self._queue_name)
        File "<string>", line 6, in receiver
        File "/usr/lib/python2.7/site-packages/qpid/messaging/endpoints.py", line 653, in receiver
          receiver.close()
        File "<string>", line 6, in close
        File "/usr/lib/python2.7/site-packages/qpid/messaging/endpoints.py", line 1114, in close
          if not self.session._ewait(lambda: self.closed, timeout=timeout):
        File "/usr/lib/python2.7/site-packages/qpid/messaging/endpoints.py", line 597, in _ewait
          self.check_error()
        File "/usr/lib/python2.7/site-packages/qpid/messaging/endpoints.py", line 586, in check_error
          raise self.error
      qpid.messaging.exceptions.NotFound: not-found: Queue not found: 17980224d7004b88b503a71c0c471bfa (/var/tmp/portage/net-misc/qpid-cpp-0.34/work/qpid-cpp-0.34/src/qpid/broker/QueueRegistry.cpp:127)(404)
      
      from qpidtoollibs import BrokerAgent
      ...
      def create_queue(self):
         queue_name = self._queue_name = uuid.uuid4().get_hex()
         agent = BrokerAgent(self._connection)
         declargs = {"auto-delete": "true"}
         agent.addQueue(queue_name, declargs)
      
      def send_request(self, content_dict):
         sender = self._session.sender(self._foo_queue_name)
         try:
            message = Message(content=json_content, reply_to=self._queue_name)
            sender.send(message)
         finally:
            sender.close()
      
      def await_response(self, timeout_secs):
         receiver = self._session.receiver(self._queue_name)
         msg = receiver.fetch(timeout=timeout_secs)
         return msg
      

      On the Java side we connect using JMS (0.8.0) and wait for a message to arrive in the "foo-bar" queue. Once it does it will create a MessageProducer using the reply-to Destination object (from the incoming Message.getJMSReplyTo) and send a response back, but when that MessageProducer is closed the auto-delete queue seems to be removed even if we have the Python client connected to it.

      A very simplified version of the Java code:

      class BrokerConnection implements MessageListener {
         Connection connection;
         Session session;
         MessageConsumer messageConsumer;
      
         public BrokerConnection(ConnectionFactory connectionFactory) {
            connection = connectionFactory.createConnection();
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            Destination queue = session.createQueue("foo-bar");
            messageConsumer = session.createConsumer(queue);
            messageConsumer.setMessageListener(this);
            connection.start();
         }
      
         public void onMessage(Message message) {
            Destination clientQueue = message.getJMSReplyTo();
      
            try (MessageProducer prod = session.createProducer(clientQueue)) {
               BytesMessage msg = session.createBytesMessage();
               msg.writeBytes(message.unwrap());
               prod.send(msg);
            } // implicit prod.close()
         }
      }
      

      The issue seems to be timing sensitive. It works more often if running on a slow machine (i.e. a virtual machine with limited resources) or if a debugger is attached to the JVM causing that to slow down.

      From this behavior we suspect a bug in the Java/JMS client code messing with the consumer count in the broker.

      Please let us know if we can provide more details to track down this issue.

        Attachments

        1. AMQP Sequence.png
          156 kB
          Paul Loberg
        2. AMQP Sequence.txt
          55 kB
          Paul Loberg

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              palloberg Paul Loberg
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: