您好,欢迎访问一九零五行业门户网

RabbitMQ Tutorials输出helloword

sending 发送方$connection = new amqpstreamconnection('localhost', 5672, 'guest', 'guest'); // 指定虚拟机 // $connection = new amqpstreamconnection('localhost', 5672, 'test1', '123456', $vhost); $channel = $connection->channel(); $channel->queue_declare('hello', false, false, false, false); $msg = new amqpmessage('hello world!'); $channel->basic_publish($msg, '', 'hello'); echo " [x] sent 'hello world!'\n"; $channel->close(); $connection->close();
receiving 收接方$connection = new amqpstreamconnection('localhost', 5672, 'guest', 'guest'); // 指定虚拟机 // $connection = new amqpstreamconnection('localhost', 5672, 'test1', '123456', $vhost); $channel = $connection->channel(); $channel->queue_declare('hello', false, false, false, false); echo ' [*] waiting for messages. to exit press ctrl+c', "\n"; $callback = function($msg) { echo " [x] received ", $msg->body, "\n"; }; $channel->basic_consume('hello', '', false, true, false, false, $callback); while(count($channel->callbacks)) { $channel->wait(); }
以上就是rabbitmq tutorials输出helloword的详细内容。
其它类似信息

推荐信息