PHPackages                             hanwenbo/rabbitmq - 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. hanwenbo/rabbitmq

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

hanwenbo/rabbitmq
=================

easyswoole rabbitmq pool

1.0.0(4y ago)013Apache-2.0PHP

Since Jul 1Pushed 4y ago1 watchersCompare

[ Source](https://github.com/hanwenbo/php-rabbitmq)[ Packagist](https://packagist.org/packages/hanwenbo/rabbitmq)[ Docs](https://www.easyswoole.com/)[ RSS](/packages/hanwenbo-rabbitmq/feed)WikiDiscussions master Synced 3w ago

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

```
composer require hanwenbo\rabbitmq

```

第一步-配置：

```
    'RABBITMQ' => [
        'host' => '172.22.0.2',
        'port' => 5672,
        'user' => 'jddtest',
        'passwd' => 'jddtest',
        'vhost' => '/' ,  // 自己创建的任意host名字
    ],
    'RABBITMQ_CHANNEL' => [
        'exchange' => 'exchange',
        'queue' => 'queue',
        'routekey' => '',
        'connectionPoolName' => 'rabbitmq-pool'
    ],
```

第二步-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', new RabbitMQConfig(Config::getInstance()->getConf('RABBITMQ')));
        $rabbitmqPoolConfig->setMinObjectNum(1);
        $rabbitmqPoolConfig->setMaxObjectNum(2);
        $rabbitmqPoolConfig->setIntervalCheckTime(30);
        $rabbitmqPoolConfig->setMaxIdleTime(30000000);
        // 废弃了
//        $rabbitmqChannelPoolConfig = RabbitMQChannel::getInstance()->register('rabbitmq-channel-pool', new RabbitMQChannelConfig(Config::getInstance()->getConf('RABBITMQ_CHANNEL')));
//        $rabbitmqChannelPoolConfig->setMaxIdleTime(3000000);
    }
```

第三步-使用：

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

    private function channelInvoke($params)
    {
        try {
            $res = RabbitMQChannel::invoke('rabbitmq-channel-pool', function (AMQPChannel $channel) use ($params) {
                $exchange = 'exchange';
                $messageBody = "这是内容1";
                $message = new AMQPMessage($messageBody, array('content_type' => 'text/plain', 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT));
                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

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

1462d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ff4efaf379c6fae90645ba663b1ca2e6b2ac36d026dfdd473ebab4db5a476e05?d=identicon)[hanwenbo](/maintainers/hanwenbo)

---

Top Contributors

[![hanwenbo](https://avatars.githubusercontent.com/u/5869741?v=4)](https://github.com/hanwenbo "hanwenbo (2 commits)")

---

Tags

rabbitmqswoolepooleasyswoole

### Embed Badge

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

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

###  Alternatives

[bschmitt/laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages

2822.5M7](/packages/bschmitt-laravel-amqp)[convenia/pigeon

3334.8k](/packages/convenia-pigeon)[easyswoole/wechat

Coroutine safety WeChat library

8242.5k10](/packages/easyswoole-wechat)

PHPackages © 2026

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