【rabbitmq-Php】-发布Publish 与订阅Subscribe
发布/订阅,使用扇型交换机(fanout) composer.json ### composer.json { "require": { "php-amqplib/php-amqplib": ">=2.9.0" } } 发布端(Publish) /** * rabbitmq * 发布/订阅 * Publish * https://github.com/rabbitmq/rabbitmq-tutorials * https://www.rabbitmq.com/tutorials/tutorial-three-php.html */ defined('DS') or define('DS', DIRECTORY_SEPARATOR); require_once __DIR__. DS . 'vendor' .DS.'autoload.php'; use PhpAmqpLib\Connection\AMQPStreamConnection; use PhpAmqpLib\Message\AMQPMessage; $connection = new AMQPStreamConnection('192.168.0.83', 5672, 'admin', 'admin'); $channel = $connection->channel(); // 创建一个fanout类型的交换机