如何从 RabbitMQ 中删除队列绑定?

发布于 2024-10-03 15:51:25 字数 195 浏览 0 评论 0原文

我正在使用 RabbitMQ 按主题将消息路由到感兴趣的订阅者。每个订阅者都有一个队列,我将队列绑定到他们感兴趣的主题。我想允许用户从他们的主题列表中删除一个项目。

在我的设置中,这需要从该用户的队列中“解除绑定”绑定主题。

我正在使用 pyamqplib,但我没有找到通过通道对象执行此操作的方法。他们是从队列中删除先前绑定的路由键的方法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风追烟花雨 2024-10-10 15:51:25
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);
   }
}
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);
   }
}
超可爱的懒熊 2024-10-10 15:51:25

使用 Python 工作?

在我看来,pika 0.13 有一个 解绑方法

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

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文