10

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?

Tony Lenzi
  • 4,219
  • 5
  • 31
  • 25

3 Answers3

5
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);
   }
}
imennez
  • 51
  • 1
  • 2
2

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)
Dan H
  • 14,044
  • 6
  • 39
  • 32
1

Does this

How to selectively delete messages from an AMQP (RabbitMQ) queue?

solve your problem?

Community
  • 1
  • 1
Rupeshit
  • 1,476
  • 1
  • 14
  • 23