iconvt / tswoft-rabbitmq
基于swoft封装的rabbitmq连接池
v1.0.2
2019-12-12 05:58 UTC
Requires
- swoft/connection-pool: ~2.0.0
- swoft/framework: ~2.0.0
- swoft/php-amqplib: ~2.0.0
This package is auto-updated.
Last update: 2025-03-13 14:50:54 UTC
README
rabbitmq-pool swoft 仿redis-pool
配置
bean.php
return [ 'rabbitMq' =>[ 'class' => \Ticonv\Swoft\RabbitMq\MqClient::class, 'host' => '127.0.0.1', 'port' => 5672, 'userName' => 'admin', 'passWord' => '******', 'setting' => [ 'vhost' => '/', 'insist' => false, 'login_method'=>'AMQPLAIN', 'login_response'=>null, 'locale'=>'en_US', 'connection_timeout'=>3.0, 'read_write_timeout'=>3.0, 'context'=>null, 'keepalive'=>false, 'heartbeat'=>0 ] ], 'rabbitMq.pool' => [ 'class' => \Ticonv\Swoft\RabbitMq\Pool::class, 'client'=> bean(\Ticonv\Swoft\RabbitMq\MqClient::class), 'maxActive' => 10 ] ]
使用
$pool = bean(\Ticonv\Swoft\RabbitMq\Pool::class); $connection = $pool->connect(); $client = $connection->getClient(); $channel = $client->channel(); $channel->queue_declare('hello', false, false, false, false); $msg = new AMQPMessage('Hello World!'); $channel->basic_publish($msg, '', 'hello'); $channel->close();