本文介绍了RabbitMQ:检查队列是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 rabbitMQ,可以使用 channel.queueDeclarePassive 检查队列是否存在,如果是后者则抛出异常.但是,该频道也将被终止.

For rabbitMQ it can be checked with channel.queueDeclarePassive if a queue exists or not, throwing an exception if the later is the case. However, also the channel will be terminated then.

如何检查队列是否存在,否则通道将被终止?

How can I check if a queue exists, without that the channel will be terminated?

谢谢

推荐答案

您可以重新声明队列,而不是被动地.

you could redeclare the queue, not passively.

channel.queueDeclare

如果队列已经存在,这将不执行任何操作,或者创建队列.

this will either do nothing if the queue already exists, or it will create the queue.

但至于检查它是否存在,无需重新创建它,queueDeclarePassive 是您唯一真正的选择.

but as for checking if it exists, without recreating it, queueDeclarePassive is your only real option.

这篇关于RabbitMQ:检查队列是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 11:53
查看更多