PHP基于rabbitmq操作类的生产者和消费者功能示例(2)

<?php error_reporting(0); include_once('RabbitMQCommand.php'); $configs = array('host'=>'127.0.0.1','port'=>5672,'username'=>'asdf','password'=>'123456','vhost'=>'https://www.jb51.net/'); $exchange_name = 'class-e-1'; $queue_name = 'class-q-1'; $route_key = 'class-r-1'; $ra = new RabbitMQCommand($configs,$exchange_name,$queue_name,$route_key); class A{ function processMessage($envelope, $queue) { $msg = $envelope->getBody(); $envelopeID = $envelope->getDeliveryTag(); $pid = posix_getpid(); file_put_contents("log{$pid}.log", $msg.'|'.$envelopeID.''."\r\n",FILE_APPEND); $queue->ack($envelopeID); } } $a = new A(); $s = $ra->run(array($a,'processMessage'),false);

更多关于PHP相关内容感兴趣的读者可查看本站专题:《PHP数据结构与算法教程》、《php程序设计算法总结》、《php字符串(string)用法总结》、《PHP数组(Array)操作技巧大全》、《PHP常用遍历算法与技巧总结》及《PHP数学运算技巧总结

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/9893c4bffe3b4c85f123b39c21f2857a.html