• <legend id='PZXvz'><style id='PZXvz'><dir id='PZXvz'><q id='PZXvz'></q></dir></style></legend>

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

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

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

      3. rabbitmq AMQP::consume()

        时间:2023-11-30

          <legend id='lK6m4'><style id='lK6m4'><dir id='lK6m4'><q id='lK6m4'></q></dir></style></legend>
            <tbody id='lK6m4'></tbody>

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

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

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

                  本文介绍了rabbitmq AMQP::consume()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  AMQP 函数 consume() 是一个带有回调的阻塞函数,是否可以为 consume() 函数设置超时,这样在特定时间后它不再阻塞并且代码执行完成?

                  AMQP function consume() is a blocking function with a callback, Is it possible to set a timeout for consume() function, so after specific amount of time it doesn't block anymore and the code execution completes ?

                  推荐答案

                  是的,方法如下:

                  $amqp = new AMQPConnection($your_connection_params);
                  $amqp->setTimeout($seconds);
                  

                  那么当你在队列上调用consume()时,如果在超时时间内没有消息到达,consume()会抛出一个AMQPException,消息是资源暂时不可用".如果您曾经中断消费()或遇到超时,请务必在队列对象上调用取消()以正确重置消费者.为此,您需要生成一个全局唯一的消费者标签,并将其作为未记录的第三个参数传入消费:

                  Then when you call consume() on a queue, if no messages arrive within the timeout period, an AMQPException will be thrown from consume() with the message, "Resource temporarily unavailable". If you ever break out of consume() or hit a timeout, be sure to call cancel() on the queue object to properly reset the consumer. In order to do this, you need to generate a globally unique consumer tag and pass it in as an undocumented, third parameter to consume:

                  $tag = uniqid() . microtime(true);
                  $queue->consume($callback, $flags, $tag);
                  $queue->cancel($tag);
                  

                  这样,您以后可以再次调用consume(),而不会出现令您头晕目眩的奇怪问题.

                  That way, you can call consume() again later without weird issues that will make your head spin.

                  这篇关于rabbitmq AMQP::consume()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Windows 10 &amp; 中安装 AMQPPHP 7.3 下一篇:从 RabbitMQ 队列中检索消息

                  相关文章

                • <tfoot id='FS49f'></tfoot>
                  1. <small id='FS49f'></small><noframes id='FS49f'>

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

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