断开rabbitmq连接的方法

发布于 2024-11-30 14:16:00 字数 127 浏览 2 评论 0原文

我有一个有一些错误的应用程序。由于某种原因,当只有一个消费者应该存在时,却创建了 2 个消费者 - 并且其中一个不再检查消息。

我可以通过列出服务器上的队列和消费者数量来检测这种情况。有什么方法可以从服务器端销毁该消费者吗?

I've got an application which has some bugs. For some reason 2 consumers are created when only one should be there - and one of them is not checked for messages anymore.

I can detect that situation by listing queues and the number of consumers on the server. Is there some way to destroy that consumer from the server side?

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

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

发布评论

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

评论(3

私藏温柔 2024-12-07 14:16:00

消费者可以通过 rabbitmqctl 使用 close_connection 输入connectionpid

示例

> rabbitmqctl close_connection "<[email protected]>" "reason here"

获取

> rabbitmqctl list_consumers

Listing consumers ...
send_email_1    <[email protected]>   amq.ctag-oim8CCP2hsioWc-3WwS-qQ true    1   []
send_email_2    <[email protected]>   amq.ctag-WxpxDglqZQN2FNShN4g7QA true    1   []

connectionpid可以通过RabbitMQ 3.5.4

consumer can be kill by rabbitmqctl using close_connection input connectionpid

example

> rabbitmqctl close_connection "<[email protected]>" "reason here"

connectionpid can get by

> rabbitmqctl list_consumers

Listing consumers ...
send_email_1    <[email protected]>   amq.ctag-oim8CCP2hsioWc-3WwS-qQ true    1   []
send_email_2    <[email protected]>   amq.ctag-WxpxDglqZQN2FNShN4g7QA true    1   []

RabbitMQ 3.5.4

寄与心 2024-12-07 14:16:00

您可以使用rabbitmqctl工具终止与RabbitMQ代理的连接(请参阅手册页)或使用 网络用户界面。您还可以清除并删除属于恶意消费者的队列。

但是,您无法使用这些工具终止消费者进程本身。您确实应该专注于修复应用程序中的错误,以便只创建正确数量的消费者。

You can kill connections to the RabbitMQ broker using the rabbitmqctl tool (see the man page) or by using the Web UI. You could also purge and delete the queue which belonged to the rogue consumer.

However, you can't kill the consumer process itself using those tools. You really should just focus on fixing the bugs in the application so that only the correct number of consumers get created.

素食主义者 2024-12-07 14:16:00

您需要将您的消费者标记为“独家”。然后只有一个消费者注册到队列中,而其他消费者即使尝试从该队列获取数据也会被忽略。

You need to mark you consumer as "exclusive". Then only one consumer is registered with queue and other consumers are ignored even they tries to get data from that queue.

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