PHPackages                             itholiday/rabbitmq-pool - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. itholiday/rabbitmq-pool

ActiveLibrary[Queues &amp; Workers](/categories/queues)

itholiday/rabbitmq-pool
=======================

easyswoole rabbitmq pool

v1.0.0(5y ago)211[1 issues](https://github.com/itholiday/rabbitmq-pool/issues)Apache-2.0PHP

Since Jun 24Pushed 5y ago2 watchersCompare

[ Source](https://github.com/itholiday/rabbitmq-pool)[ Packagist](https://packagist.org/packages/itholiday/rabbitmq-pool)[ Docs](https://www.easyswoole.com/)[ RSS](/packages/itholiday-rabbitmq-pool/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

easyswoole rabbitmq pool

第一步-配置：

```
    'RABBITMQ_1' => [
        'host' => '192.168.199.217',
        'port' => 5672,
        'user' => 'jddtest',
        'passwd' => 'jddtest',
        'vhost' => '/'
    ],
    'RABBITMQ_CHANNEL_1' => [
        'exchange' => 'router',
        'queue' => 'msgs',
        'routekey' => '',
        'connectionPoolName' => 'rabbitmq-pool-1'
    ],
```

第二步-EasySwooleEvent.php文件中initialize方法中注册：

```
class EasySwooleEvent implements Event
{

    public static function initialize()
    {
        // TODO: Implement initialize() method.
        date_default_timezone_set('Asia/Shanghai');
        // rabbitmq-pool
        $rabbitmqPoolConfig = RabbitMQ::getInstance()->register('rabbitmq-pool-1', new RabbitMQConfig(Config::getInstance()->getConf('RABBITMQ_1')));
        $rabbitmqPoolConfig->setMinObjectNum(1);
        $rabbitmqPoolConfig->getMaxObjectNum(2);
        $rabbitmqPoolConfig->setIntervalCheckTime(30);
        $rabbitmqPoolConfig->setMaxIdleTime(30000000);
        $rabbitmqChannelPoolConfig = RabbitMQChannel::getInstance()->register('rabbitmq-channel-pool', new RabbitMQChannelConfig(Config::getInstance()->getConf('RABBITMQ_CHANNEL_1')));
        $rabbitmqChannelPoolConfig->setMaxIdleTime(3000000);
    }
```

第三步-使用：

```
    public function rabbitmq()
    {
        $request = $this->request();
        $params = $request->getRequestParam();
        //rabbitmq-pool
        go(function () use ($params) {

            //直接初始化channel 如果连接重启EasySwoole\RabbitMQPool\RabbitMQChannelPool pool is empty
            $times = 3;
            while ($times > 0) {
                $res = $this->channelInvoke($params);
                if ($res === true) {
                    break;
                }
                var_dump($res, $times);
                $times --;
            }

//            // 初始化connection
//            \EasySwoole\RabbitMQPool\RabbitMQ::invoke('rabbitmq-pool', function (AMQPStreamConnection $rabbitmq) use ($params) {
//                $channel = $rabbitmq->channel();
//                $exchange = 'router';
//                $exchange = $params['exchange'];
//                $queue = 'msgs';
//                $queue = $params['queue'];
//                $msg = $params['msg'];
//                $channel->queue_declare($queue, false, true, false, false);
//                $channel->exchange_declare($exchange, AMQPExchangeType::DIRECT, false, true, false);
//                $channel->queue_bind($queue, $exchange);
//                $messageBody = "{'name'=>'jsk', 'age' => 12, 'msg'=> '失败的请求数量。因网络原因或服务器性能原因，发起的请求并不一定全部成功，通过'}";
//                $messageBody = $msg;
//                $message = new AMQPMessage($messageBody, array('content_type' => 'text/plain', 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT));
//                $channel->basic_publish($message, $exchange);
//                $channel->close();
//            });
        });
        $this->writeJson(200, $params);

    }

    private function channelInvoke($params)
    {
        try {
            $res = RabbitMQChannel::invoke('rabbitmq-channel-pool', function (AMQPChannel $channel) use ($params) {
                $exchange = 'router';
                $exchange = $params['exchange'];
                $queue = 'msgs';
                $queue = $params['queue'];
                $msg = $params['msg'];
                $messageBody = $msg;
                $message = new AMQPMessage($messageBody, array('content_type' => 'text/plain', 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT));
                // 如果connection关闭了，channel-pool不会一并回收。
                try {
                    $channel->basic_publish($message, $exchange);
                    return true;
                } catch (\Exception $exception) {
                    var_dump($exception->getMessage());
                    return false;
                }
            });
            return $res;
        } catch (\Exception $exception) {
            var_dump($exception->getMessage());
            return false;
        }
    }
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2146d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f8db32a049bd493bc30a1586974f2adf99667b5fa01bea20eade2b73721f743?d=identicon)[itholiday](/maintainers/itholiday)

---

Top Contributors

[![itholiday](https://avatars.githubusercontent.com/u/12675040?v=4)](https://github.com/itholiday "itholiday (1 commits)")

---

Tags

rabbitmqswoolepooleasyswoole

### Embed Badge

![Health badge](/badges/itholiday-rabbitmq-pool/health.svg)

```
[![Health](https://phpackages.com/badges/itholiday-rabbitmq-pool/health.svg)](https://phpackages.com/packages/itholiday-rabbitmq-pool)
```

###  Alternatives

[php-amqplib/rabbitmq-bundle

Integrates php-amqplib with Symfony &amp; RabbitMq. Formerly emag-tech-labs/rabbitmq-bundle, oldsound/rabbitmq-bundle.

1.3k20.1M64](/packages/php-amqplib-rabbitmq-bundle)[bschmitt/laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages

2752.3M7](/packages/bschmitt-laravel-amqp)[php-amqplib/thumper

AMQP Tools

276210.8k7](/packages/php-amqplib-thumper)[easyswoole/wechat

Coroutine safety WeChat library

8140.8k4](/packages/easyswoole-wechat)[mikemadisonweb/yii2-rabbitmq

Wrapper based on php-amqplib to incorporate messaging in your Yii2 application via RabbitMQ. Inspired by RabbitMqBundle for Symfony 2, really awesome package.

74262.1k1](/packages/mikemadisonweb-yii2-rabbitmq)[simple-bus/rabbitmq-bundle-bridge

Use OldSoundRabbitMQBundle with SimpleBus/AsynchronousBundle

39827.3k4](/packages/simple-bus-rabbitmq-bundle-bridge)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
