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

Unbind queue causes connection failure when using AMQP 0-9-1

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.12, 0.15
    • Fix Version/s: 0.15
    • Component/s: Java Broker
    • Labels:
      None

      Description

      The broker sends a FIN after receiving an unbind queue command. The stack trace (below) shows a ClassCastException caused by attempting to cast a MethodRegistry_0_91 to a MethodRegistry_0_9. The offending line of code appears to be line 117 in the QueueUnbindHandler (trunk):

      MethodRegistry_0_9 methodRegistry = (MethodRegistry_0_9) session.getMethodRegistry();

      Compare to line 153 in QueueBindHandler (trunk) which reads:

      MethodRegistry methodRegistry = protocolConnection.getMethodRegistry();

      Note: reproduced against version 0.12 and trunk r1221838.

      2011-12-20 15:23:53,157 INFO [pool-3-thread-19] logging.Log4jMessageLogger (Log4jMessageLogger.java:72) - [con:0(guest@/127.0.0.1:51326/test)/ch:2] [vh(/test)/ex(fanout/demo_exchange)/qu(client259647)/rk(broadcastkey)] BND-1002 : Deleted
      2011-12-20 15:23:53,158 ERROR [pool-3-thread-19] protocol.AMQProtocolEngine (AMQProtocolEngine.java:456) - Unexpected exception while processing frame. Closing connection.
      java.lang.ClassCastException: org.apache.qpid.framing.amqp_0_91.MethodRegistry_0_91 cannot be cast to org.apache.qpid.framing.amqp_0_9.MethodRegistry_0_9
      at org.apache.qpid.server.handler.QueueUnbindHandler.methodReceived(QueueUnbindHandler.java:117)
      at org.apache.qpid.server.handler.ServerMethodDispatcherImpl_0_91.dispatchQueueUnbind(ServerMethodDispatcherImpl_0_91.java:165)
      at org.apache.qpid.framing.amqp_0_91.QueueUnbindBodyImpl.execute(QueueUnbindBodyImpl.java:152)
      at org.apache.qpid.server.state.AMQStateManager.methodReceived(AMQStateManager.java:205)
      at org.apache.qpid.server.protocol.AMQProtocolEngine.methodFrameReceived(AMQProtocolEngine.java:390)
      at org.apache.qpid.framing.AMQMethodBodyImpl.handle(AMQMethodBodyImpl.java:93)
      at org.apache.qpid.server.protocol.AMQProtocolEngine.frameReceived(AMQProtocolEngine.java:334)
      at org.apache.qpid.server.protocol.AMQProtocolEngine.dataBlockReceived(AMQProtocolEngine.java:283)
      at org.apache.qpid.server.protocol.AMQProtocolEngine$1.run(AMQProtocolEngine.java:254)
      at org.apache.qpid.pool.Job.processAll(Job.java:110)
      at org.apache.qpid.pool.Job.run(Job.java:149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)

        Activity

        Hide
        k-wall Keith Wall added a comment - - edited

        Hello Frank,

        Yes, I agree, this is a defect in the QueueUnbindHandler. It needs to check the protocol version and cast to the appropriate MethodRegistry: MethodRegistry_0_9 or MethodRegistry_0_91 as QueueUnbind exists only in the 0-9 and 0-9-1 protocol versions. The code fix is straightforward and I plan to commit a change. Automated testing from Java will require more changes as currently QueueUnbind is not exposed through the Java Qpid client API.

        Just out of interest, which Qpid client do you use? As a workaround in the meanwhile, you could consider using the JMX ManagedExchange.removeBinding operation.

        Hope this helps, Keith.

        Show
        k-wall Keith Wall added a comment - - edited Hello Frank, Yes, I agree, this is a defect in the QueueUnbindHandler. It needs to check the protocol version and cast to the appropriate MethodRegistry: MethodRegistry_0_9 or MethodRegistry_0_91 as QueueUnbind exists only in the 0-9 and 0-9-1 protocol versions. The code fix is straightforward and I plan to commit a change. Automated testing from Java will require more changes as currently QueueUnbind is not exposed through the Java Qpid client API. Just out of interest, which Qpid client do you use? As a workaround in the meanwhile, you could consider using the JMX ManagedExchange.removeBinding operation. Hope this helps, Keith.
        Hide
        k-wall Keith Wall added a comment -

        Hi Robbie, would you review please?

        Is there a reason why there is no AMQSession#unbindQueue (analogous to #bindQueue). It would be straightforward to do so.

        cheers, Keith

        Show
        k-wall Keith Wall added a comment - Hi Robbie, would you review please? Is there a reason why there is no AMQSession#unbindQueue (analogous to #bindQueue). It would be straightforward to do so. cheers, Keith
        Hide
        brennan.gaunce Brennan Gaunce added a comment -

        I will return January 2.

        Show
        brennan.gaunce Brennan Gaunce added a comment - I will return January 2.
        Hide
        gemmellr Robbie Gemmell added a comment -

        It would be nice to avoid the casting, but I don't think its worth spending the time updating the MethodRegistry code generator to do it (also, given its an isolated incident due to the lack of 0-8 support)..so change seems reasonable

        As to why there isn't an unbind helper method in AMQSession, I guess its because we rarely if ever use that command from the Java client (certainly not with 0-9-1 given that no tests showed this).

        Show
        gemmellr Robbie Gemmell added a comment - It would be nice to avoid the casting, but I don't think its worth spending the time updating the MethodRegistry code generator to do it (also, given its an isolated incident due to the lack of 0-8 support)..so change seems reasonable As to why there isn't an unbind helper method in AMQSession, I guess its because we rarely if ever use that command from the Java client (certainly not with 0-9-1 given that no tests showed this).

          People

          • Assignee:
            gemmellr Robbie Gemmell
            Reporter:
            frank.salim Frank Salim
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development