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

ActiveLibrary

huangbin2018/rabbitmq-helper
============================

RabbitMQ 消息队列实现自动重试、异常队列

v1.0.1(6y ago)14MITPHPPHP &gt;=7.0.0

Since Jan 7Pushed 6y ago1 watchersCompare

[ Source](https://github.com/huangbin2018/rabbitmq-helper)[ Packagist](https://packagist.org/packages/huangbin2018/rabbitmq-helper)[ RSS](/packages/huangbin2018-rabbitmq-helper/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

RabbitMqHelper
==============

[](#rabbitmqhelper)

RabbitMQ 消息队列实现重试、异常处理。

流程图：

[![](https://raw.githubusercontent.com/huangbin2018/rabbitmq-helper/master/doc/image.png)](https://raw.githubusercontent.com/huangbin2018/rabbitmq-helper/master/doc/image.png)

安装
==

[](#安装)

```
 composer require huangbin2018/rabbitmq-helper
```

依赖
==

[](#依赖)

PHP &gt;= 7.0

php-amqplib/php-amqplib &gt;= 2.9

php\_amqp.dll / php\_amqp.so

使用
==

[](#使用)

参考代码 demo/demo.php

```
// RabbitMq 连接配置
$rabbitMqConfig = [
    'host' => '10.10.30.211',
    'port' => 5672,
    'user' => 'wms_server',
    'password' => 'jf67DfRghk32f8o0',
    'vhost' => 'wms',
];
$mqObj = RabbitMqInstance::getInstance($rabbitMqConfig);
$isDelayed = false; // 是否为延时队列
// 读消息
$ret = $mqObj->getQueueMessage('demo.user.del', 'demo.user.delete', 'demoExChange', 10, $isDelayed, '');
var_dump($ret);

//生产者 发送消息
$publisher = $mqObj->getPublisherByExChange('demoExChange', $isDelayed);
for($i = 0; $i  'demo_' . $i,
        'user_id' => $i,
        'user_password' => md5(rand(0, 1000) . time()),
        'add_date' => date('Y-m-d H:i:s'),
    ];
    $source = 'mq_source'; // 消息来源
    $message = new \RabbitMqHelper\RabbitMQRetry\Message($data, $source);
    try {
        $publisher->publish($message, 'demo.user.add', true, 30); // 延时 30 秒
        $publisher->publish($message, 'demo.user.delete', true, 10);
        $publisher->publish($message, 'demo.user.edit', true);
    } catch (\Exception $e) {
        // 发生异常....
    }
}

// 启动消息消费者监听(阻塞模式)
// routingKey 路由匹配模式 * 匹配一个单词，# 匹配0个或者多个单词
// 如果 “*” and “#” 没有被使用，那么topic exchange就变成了direct exchange
$subConfig = [
    'queueName' => 'demo.user.add',
    'routingKey' => 'demo.user.add',
    'exchangeName' => 'demoExChange'
];
$mqCls->execSubscriber($subConfig, function (\RabbitMqHelper\RabbitMQRetry\SubMessage $message) {
    // TODO 业务逻辑实现
    echo date('Y-m-d H:i:s') . PHP_EOL;
    echo sprintf(
        "subscriber Message:\n RoutingKey \n MessageBody: %s\n",
        $message->getRoutingKey(),
        $message->getMessage()->serialize()
    );
    echo "================================================\n";

    // 业务处理逻辑

    // ask 处理成功返回 success (返回 success 后将会对消息进行处理确认)，失败返回 failure （消息会重试处理）
    $returnSuccess = ['ask' => 'Success', 'message' => 'isSuccess'];
    $returnFailure = ['ask' => 'Failure', 'message' => 'Failure Message'];

    return $returnSuccess;
}, false, $isDelayed);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Every ~0 days

Total

2

Last Release

2317d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9979f6356775b5a3949ebe2639f8b4da61d58c691d15356c6c995ba0ed1cf491?d=identicon)[huangbin2018](/maintainers/huangbin2018)

---

Top Contributors

[![huangbin2018](https://avatars.githubusercontent.com/u/36786839?v=4)](https://github.com/huangbin2018 "huangbin2018 (7 commits)")

### Embed Badge

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

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

###  Alternatives

[phan/phan

A static analyzer for PHP

5.6k11.2M1.1k](/packages/phan-phan)[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)[php-soap/wsdl-reader

A WSDL reader in PHP

212.3M9](/packages/php-soap-wsdl-reader)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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