<i id='oKYUO'><tr id='oKYUO'><dt id='oKYUO'><q id='oKYUO'><span id='oKYUO'><b id='oKYUO'><form id='oKYUO'><ins id='oKYUO'></ins><ul id='oKYUO'></ul><sub id='oKYUO'></sub></form><legend id='oKYUO'></legend><bdo id='oKYUO'><pre id='oKYUO'><center id='oKYUO'></center></pre></bdo></b><th id='oKYUO'></th></span></q></dt></tr></i><div id='oKYUO'><tfoot id='oKYUO'></tfoot><dl id='oKYUO'><fieldset id='oKYUO'></fieldset></dl></div>

      <tfoot id='oKYUO'></tfoot>

          <bdo id='oKYUO'></bdo><ul id='oKYUO'></ul>

      1. <small id='oKYUO'></small><noframes id='oKYUO'>

        <legend id='oKYUO'><style id='oKYUO'><dir id='oKYUO'><q id='oKYUO'></q></dir></style></legend>

        如何检查 RabbitMQ 消息队列是否存在?

        时间:2023-08-24

        <i id='DX1hG'><tr id='DX1hG'><dt id='DX1hG'><q id='DX1hG'><span id='DX1hG'><b id='DX1hG'><form id='DX1hG'><ins id='DX1hG'></ins><ul id='DX1hG'></ul><sub id='DX1hG'></sub></form><legend id='DX1hG'></legend><bdo id='DX1hG'><pre id='DX1hG'><center id='DX1hG'></center></pre></bdo></b><th id='DX1hG'></th></span></q></dt></tr></i><div id='DX1hG'><tfoot id='DX1hG'></tfoot><dl id='DX1hG'><fieldset id='DX1hG'></fieldset></dl></div>

          <small id='DX1hG'></small><noframes id='DX1hG'>

              <bdo id='DX1hG'></bdo><ul id='DX1hG'></ul>
            • <tfoot id='DX1hG'></tfoot>

                  <tbody id='DX1hG'></tbody>
                  <legend id='DX1hG'><style id='DX1hG'><dir id='DX1hG'><q id='DX1hG'></q></dir></style></legend>
                  本文介绍了如何检查 RabbitMQ 消息队列是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何检查消息队列是否已经存在?

                  How can I check whether a message Queue already exists or not?

                  我有 2 个不同的应用程序,一个创建队列,另一个从该队列读取.

                  I have 2 different applications, one creating a queue and the other reading from that queue.

                  所以如果我运行首先从队列中读取的客户端,它就会崩溃.
                  所以为了避免这种情况,我想先检查队列是否存在.

                  So if I run the Client which reads from the queue first, than it crashes.
                  So to avoid that i would like to check first whether the queue exists or not.

                  这是我如何读取队列的代码片段:

                  here is the code snippet of how I read the queue:

                  QueueingBasicConsumer <ConsumerName> = new QueueingBasicConsumer(<ChannelName>); 
                  <ChannelName>.BasicConsume("<queuename>", null, <ConsumerName>); 
                  BasicDeliverEventArgs e = (BasicDeliverEventArgs)<ConsumerName>.Queue.Dequeue();
                  

                  推荐答案

                  不用检查了.

                  queue.declare 是幂等操作.所以,如果你运行一次,两次,N次,结果还是一样的.

                  queue.declare is an idempotent operation. So, if you run it once, twice, N times, the result will still be the same.

                  如果要确保队列存在,只需在使用前声明即可.确保每次都以相同的持久性、排他性、自动删除性声明它,否则你会得到一个例外.

                  If you want to ensure that the queue exists, just declare it before using it. Make sure you declare it with the same durability, exclusivity, auto-deleted-ness every time, otherwise you'll get an exception.

                  如果您确实需要检查队列是否存在(通常不需要),请对队列进行被动声明.如果队列存在,则该操作成功,如果不存在,则操作失败.

                  If you actually do need to check if a queue exists (you shouldn't normally need to), do a passive declare of the queue. That operation succeeds if the queue exists, or fails in an error if it doesn't.

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

                  上一篇:具有 MassTransit、RabbitMQ 和 SignalR 的分布式架构 下一篇:基于多线程的 RabbitMQ 消费者

                  相关文章

                  最新文章

                1. <tfoot id='sKGeC'></tfoot><legend id='sKGeC'><style id='sKGeC'><dir id='sKGeC'><q id='sKGeC'></q></dir></style></legend>

                    • <bdo id='sKGeC'></bdo><ul id='sKGeC'></ul>

                    <small id='sKGeC'></small><noframes id='sKGeC'>

                    1. <i id='sKGeC'><tr id='sKGeC'><dt id='sKGeC'><q id='sKGeC'><span id='sKGeC'><b id='sKGeC'><form id='sKGeC'><ins id='sKGeC'></ins><ul id='sKGeC'></ul><sub id='sKGeC'></sub></form><legend id='sKGeC'></legend><bdo id='sKGeC'><pre id='sKGeC'><center id='sKGeC'></center></pre></bdo></b><th id='sKGeC'></th></span></q></dt></tr></i><div id='sKGeC'><tfoot id='sKGeC'></tfoot><dl id='sKGeC'><fieldset id='sKGeC'></fieldset></dl></div>