当前位置:   article > 正文

php+rabbitmq消息延时队列_php amqpmessage

php amqpmessage

生产端

  1. $connection = new AMQPStreamConnection('192.168.16.111', 5672, 'user', '123456', '/', true);
  2. $channel = $connection->channel();
  3. $exchange = 'delayed_exchange_test1';
  4. //交换机类型
  5. $args = new AMQPTable(['x-delayed-type' => 'fanout']);
  6. //声明交换机
  7. $channel->exchange_declare($exchange, 'x-delayed-message', false, true, false, false, false, $args);
  8. $data = 'Hello World at ' . date('Y-m-d H:i:s');
  9. //'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT消息持久化
  10. $message = new AMQPMessage($data, ['delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT]);
  11. $delay = 10000;
  12. //延时设置
  13. $headers = new AMQPTable(['x-delay' => $delay]);
  14. $message->set('application_headers', $he
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/575006
推荐阅读
相关标签
  

闽ICP备14008679号