Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you remove a queue binding from RabbitMQ?

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?

like image 734
Tony Lenzi Avatar asked Nov 23 '10 15:11

Tony Lenzi


2 Answers

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)
like image 98
Dan H Avatar answered Sep 21 '22 15:09

Dan H


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);
   }
}
like image 39
imennez Avatar answered Sep 20 '22 15:09

imennez