断开rabbitmq连接的方法
我有一个有一些错误的应用程序。由于某种原因,当只有一个消费者应该存在时,却创建了 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
消费者可以通过
rabbitmqctl
使用 close_connection 输入connectionpid
示例
获取
connectionpid可以通过RabbitMQ 3.5.4
consumer can be kill by
rabbitmqctl
using close_connection inputconnectionpid
example
connectionpid can get by
RabbitMQ 3.5.4
您可以使用
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.
您需要将您的消费者标记为“独家”。然后只有一个消费者注册到队列中,而其他消费者即使尝试从该队列获取数据也会被忽略。
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.