How do you remove a queue binding from RabbitMQ?

14.5k Views Asked by At

I am using RabbitMQ to route messages to interested subscribers by topic. Each subscriber has a queue, and I bind the queue to the topics they are interested in. I would like to allow the user to remove an item from their topic list.

In my setup, that would require "unbinding" the bound topic from that user's queue.

I am using pyamqplib, and I am not seeing a way to do this via the channel object. Is their a way to remove previously bound routing keys from a queue?

3

There are 3 best solutions below

0
On
public void unsubscribe(String queuename, String topic) throws IOException
{
   ConnectionFactory factory = new ConnectionFactory();
   factory.setHost(MQ_HOST);
   factory.setPort(MQ_PORT);

   Connection connection = factory.newConnection();
   Channel channel = connection.createChannel();
   try
   {
      channel.exchangeDeclarePassive("Channel name");
      channel.queueUnbind(queuename, "Channel name", topic);
   }
   finally
   {
      handleClose(connection, channel);
   }
}
0
On

Working in Python?

Looks to me like pika 0.13 has an unbind method:

queue_unbind(queue, exchange=None, routing_key=None, arguments=None, callback=None)
0
On