脚本宝典收集整理的这篇文章主要介绍了如何使用PHP的RabbitMQ延迟消息队列?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我用以下代码声明交换:
$this->channel->exchange_declare( 'delay','x-delayed-message',false,/* passive,create if exchange doesn't exist */ true,/* durable,PErsist through server reboots */ false,/* autodelete */ false,/* internal */ false,/* Nowait */ ['x-delayed-type' => ['S','direct']]);
我用这段代码绑定队列:
$this->channel->queue_declare( $queueName,/* Passive */ true,/* Durable */ false,/* Exclusive */ false /* Auto Delete */ ); $this->channel->queue_bind($queueName,"delay",$queueName);
我正在使用以下代码发布消息:
$msg = new AMQPMessage(json_encode($msgData),[ 'delivery_mode' => 2,'x-delay' => 5000]); $this->channel->basic_publish($msg,'delay',$queueName);
但消息不会延迟;它仍然立即交付.我错过了什么?
以上是脚本宝典为你收集整理的如何使用PHP的RabbitMQ延迟消息队列?全部内容,希望文章能够帮你解决如何使用PHP的RabbitMQ延迟消息队列?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。