Duplicated Binding in the same queue

786 views
Skip to first unread message

Jay Zhu

unread,
Aug 26, 2014, 12:48:21 PM8/26/14
to rabbitm...@googlegroups.com
Hi - 

Does AMQP allows to have duplicate bindings in the same queue? Do I need to check if the binding exists when try to make a new one? If it does allows duplicate bindings, what's the implication?

I noticed in the RMQ Mgmt Console there are duplicated bindings in the same queue, and I have no idea how they were created. Does someone have any insight? I am on RMQ 3.2.4. The following is a snippet of the bindings in the exported JSON:
  "bindings": [
   ...
    {
      "source": "eventSource",
      "vhost": "/",
      "destination": "7b910e1e-e763-4f00-8042-0cd6fc5e5d86",
      "destination_type": "queue",
      "routing_key": "TestEvent",
      "arguments": {
        "eventEchoBack": true,
        "eventPattern": "TestEvent",
        "eventTTL": 3600
      }
    },
    {
      "source": "eventSource",
      "vhost": "/",
      "destination": "7b910e1e-e763-4f00-8042-0cd6fc5e5d86",
      "destination_type": "queue",
      "routing_key": "TestEvent",
      "arguments": {
        "eventEchoBack": true,
        "eventPattern": "TestEvent",
        "eventTTL": 3600
      }
   ...
  ]

Thanks,
Jay

Michael Klishin

unread,
Aug 26, 2014, 2:05:16 PM8/26/14
to Jay Zhu, rabbitm...@googlegroups.com


On 26 August 2014 at 20:48:28, Jay Zhu (tingj...@gmail.com) wrote:
> Does AMQP allows to have duplicate bindings in the same queue? 

Yes, just try it.

> Do I need to check if the binding exists when try to make a new one?
> If it does allows duplicate bindings, what's the implication?

All declare and bind operations are idempotent. If you bind A to B
with the same routing key, nothing changes if the same binding exists.
If the routing key is different, another binding is added to the table.

In the end, a single message can be routed to a queue only once. 
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Jason McIntosh

unread,
Aug 26, 2014, 2:49:53 PM8/26/14
to Michael Klishin, Jay Zhu, rabbitm...@googlegroups.com
Just an example I tested for this to explain just how restricted this is:  If you publish to a fanout exchange bound to two exchanges each of which is bound to the same queue, e.g. "MyBroadCastExchange" to "ExchangeA" and "ExchangeB" which are both fanouts to "MyQueue" - you'll still only get ONE message in the queue, even though ExchangeA and ExchangeB both "get a copy" of the message.  Seems a little strange to me, but I understand why that might actually be the case - both exchanges don't really get a copy of the message, they get I think an index id that correlates to the message, so you can't get duplicate messages in a queue.  At least I don't see any way to duplicate a message to a queue off hand

Jason



--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send an email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Jay Zhu

unread,
Aug 26, 2014, 7:47:38 PM8/26/14
to rabbitm...@googlegroups.com, tingj...@gmail.com
Thank you for the info Michael! Won't it make sense for RMQ to avoid duplicated binding been created between the same exchange and queue?

Thanks,
Jay

Jay Zhu

unread,
Aug 26, 2014, 7:51:06 PM8/26/14
to rabbitm...@googlegroups.com, mkli...@pivotal.io, tingj...@gmail.com
Thanks Jason.  I think same binding between 2 Exchanges to the same Queue makes sense. However duplicated bindings between the same exchange to the same queue doesn't. I would consider that as a bug in RMQ.

Thanks,
Jay

Michael Klishin

unread,
Aug 26, 2014, 7:54:45 PM8/26/14
to Jay Zhu, rabbitm...@googlegroups.com
 Jay Zhu (tingj...@gmail.com) wrote:
> > However duplicated bindings between the same exchange to the
> same queue doesn't. I would consider that as a bug in RabbitMQ.

Do you have a script that reproduces the problem? We'd be happy
to investigate.
Reply all
Reply to author
Forward
0 new messages