当前位置:   article > 正文

rabbitmq 延迟消息 php 插件 rabbitmq_delayed_message_exchange_rabbitmq_delayed_message_exchange-20171215-3.6.x.e

rabbitmq_delayed_message_exchange-20171215-3.6.x.ez

大部分介绍的rabbitmq都是利用ttl与死信的方式,rabbitmq提供的插件rabbitmq_delayed_message_exchange可以很好的实现延迟消息的功能,找了半天,网上居然没有php的例子,继而摸索了一下,参考了java的代码,总结如下:

安装流程:

下载 wget https://dl.bintray.com/rabbitmq/community-plugins/3.6.x/rabbitmq_delayed_message_exchange/rabbitmq_delayed_message_exchange-20171215-3.6.x.zip
 解压 unzip rabbitmq_delayed_message_exchange-20171215-3.6.x.zip
 移动到插件目录  mv rabbitmq_delayed_message_exchange-20171215-3.6.x.ez /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.15/plugins/
 启动 rabbitmq-plugins enable rabbitmq_delayed_message_exchange

 

对于代码来讲,首先对于发布者核心变化的代码

  1. $ex = new \AMQPExchange($channel);
  2. $ex->setName($e_name);
  3. $ex->setType('x-delayed-message');
  4. $ex->setArgument('x-delayed-type','direct');
  5. $ex->publish($message, $k_route,AMQP_NOPARAM,['headers' => ['x-delay
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/126971?site
推荐阅读
相关标签
  

闽ICP备14008679号