使用PhpAmqpLib常用的2种连接rabbitmq的方式

黑大叔 / 2023-06-24 / 原文

#connect to AMQP broker at example.com
use PhpAmqpLib\Connection\AMQPStreamConnection;
$amqp = new AMQPStreamConnection('example.com', 5672, 'user', 'pwd','/host');

#SSL or secure connection
use phpAmqpLib\Connection\AMQSSLConnection;
$amqp = new AMQPSSLConnection('domain', 5671, 'user', 'pwd','/host',['dsn'=>'amqps:']);