Search code examples
rabbitmqmessagingamqpqpid

Qpid equivalent to RabbitMQ firehose?


I've been trying to find a way to CC messages from a Qpid Exchange to another Queue for testing/monitoring purposes. I noticed that a RabbitMQ user out there was having a similar problem, and the solution seemed to be RabbitMQ's Firehose feature. Is there a similar solution in Qpid?

Here's some more details for the curious.

  • Let's call the Exchange "App.Ex", and through it are flowing messages for a single other intended recipient (let's call him "Bob")
  • I connect to App.Ex, initiate a session, start a receiver, and start fetching (using code adapted from the QPID Book's "A Simple Messaging Program in Python")
  • I start seeing the messages I want to see. HOWEVER, in doing so I've robbed Bob of the messages he needs!

So there's the rub, how can I get the messages CC'd to me, but in a way that Bob still receives his messages?

I have permission to modify the messaging configuration, so I can create my own Queues and Exchanges if need be. Thoughts appreciated!


Solution

  • A direct exchange is probably most appropriate because you can have some queues with CC like behavior and some without, and you can change it anytime on a live exchange.

    You can have two queues bound to the same subject/routing key. When a message is sent to the exchange with that particular subject/routing key, both bound queues will receives copies of the same message.

    enter image description here

    Both queues bar1 and bar2 are bound to routing_key foo. When producer B posts messages to the exchange with routing_key = foo, both bar1 and bar1 receive copies of all messages.

    Ask if you need commands for creating the exchange and appropriate bindings.

    However there are more ways to do the same thing:

    You can also achieve the similar behavior using a topic queue, with exact matches on topic name

    enter image description here

    Lastly, you can also use a fanout exchange, where any message you send to the queue, a copy is routed to all the queues bound to the exchange.

    Note that all of these exchange types are from the AMQP spec, so they are not qpid specific, you could do the same thing or something very similar in any AMQP implementation.