PHPackages                             luoxiaojun/laravel-queue-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. luoxiaojun/laravel-queue-rabbitmq

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

luoxiaojun/laravel-queue-rabbitmq
=================================

RabbitMQ driver for Laravel Queue. Supports Laravel Horizon

v8.2.0(7y ago)164MITPHPPHP ^7.1.3

Since Jan 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/luoxiaojun1992/laravel-queue-rabbitmq)[ Packagist](https://packagist.org/packages/luoxiaojun/laravel-queue-rabbitmq)[ RSS](/packages/luoxiaojun-laravel-queue-rabbitmq/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (9)Versions (39)Used By (0)

RabbitMQ Queue driver for Laravel
=================================

[](#rabbitmq-queue-driver-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/ae35fda6d3cb5b57b8d37357c6952383168d3700e346429ed5246210f4b05a48/68747470733a2f2f706f7365722e707567782e6f72672f766c6164696d69722d79756c6461736865762f6c61726176656c2d71756575652d7261626269746d712f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/luoxiaojun/laravel-queue-rabbitmq)[![Build Status](https://camo.githubusercontent.com/cd7fa6cf0c5d6c472d47c0b7df543cf1822efe48646f8d1e5748841756fce62b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7679756c6461736865762f6c61726176656c2d71756575652d7261626269746d712e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/luoxiaojun/laravel-queue-rabbitmq)[![Total Downloads](https://camo.githubusercontent.com/f38a16fd27cfaa1a90e2c6bca3d4b04a9e5d73abb89d388dabc6e4c86354c4bc/68747470733a2f2f706f7365722e707567782e6f72672f766c6164696d69722d79756c6461736865762f6c61726176656c2d71756575652d7261626269746d712f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/luoxiaojun/laravel-queue-rabbitmq)[![License](https://camo.githubusercontent.com/5d5fd5b6ae3ea751391bfefbbb234e670205414b1ec2a8e06f789a9ee277ea6b/68747470733a2f2f706f7365722e707567782e6f72672f766c6164696d69722d79756c6461736865762f6c61726176656c2d71756575652d7261626269746d712f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/luoxiaojun/laravel-queue-rabbitmq)

Installation
------------

[](#installation)

You can install this package via composer using this command:

```
composer require luoxiaojun/laravel-queue-rabbitmq:dev-master -vvv

```

The package will automatically register itself using Laravel auto-discovery.

Setup connection in `config/queue.php`

```
'connections' => [
    // ...
    'rabbitmq' => [
        'driver' => 'rabbitmq',

        'worker' => 'default',

        'dsn' => env('RABBITMQ_DSN', null),

        /*
         * Could be one a class that implements \Interop\Amqp\AmqpConnectionFactory for example:
         *  - \VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Lib\Ext\AmqpConnectionFactory if you install enqueue/amqp-ext
         *  - \VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Lib\Amqp\AmqpConnectionFactory if you install enqueue/amqp-lib
         */
        'factory_class' => env('RABBITMQ_CONN_FACTORY', \VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Lib\Ext\AmqpConnectionFactory::class),

        'host' => env('RABBITMQ_HOST', '127.0.0.1'),
        'port' => env('RABBITMQ_PORT', 5672),

        'vhost' => env('RABBITMQ_VHOST', '/'),
        'login' => env('RABBITMQ_LOGIN', 'guest'),
        'password' => env('RABBITMQ_PASSWORD', 'guest'),

        //For Aliyun
        'aliyun_access_key' => env('RABBITMQ_ALIYUN_AK'),
        'aliyun_access_secret' => env('RABBITMQ_ALIYUN_AS'),
        'aliyun_resouce_owner_id' => intval(env('RABBITMQ_ALIYUN_OWNER')),
        'max_delay' => intval(env('RABBITMQ_MAX_DELAY', 86400000)), //ms
        'delay_strategy' => \Enqueue\AmqpTools\RabbitMqDelayPluginDelayStrategy::class, // or null for Aliyun

        'queue' => env('QUEUE_NAME', 'default'),

        'queue_name_prefix' => env('RABBITMQ_QUEUE_NAME_PREFIX'),

        'persisted' => boolval((int)env('RABBITMQ_PERSISTED', false)), //only for amqp-ext

        'options' => [

            'producer' => [
                'queueTopicExchangeMapping' => [
                    'test_queue' => [
                        'topic' => 'test_topic', // string, default is queue name
                        'exchange' => 'test_exchange', //string, default is global name or queue name
                    ],
                ],

                'retry_on_connect_error' => boolval((int)env('RABBITMQ_RETRY_ON_CONN_ERROR', true)),

                'aggQueue' => [
                    //
                ],
            ],

            'consumer' => [
                'queueTopicExchangeMapping' => [
                    'test_queue' => [
                        [
                            'topic' => 'test_topic', // string or array, default is queue name
                            'exchange' => 'test_exchange', //string, default is global name or queue name
                        ],
                    ],
                ],
                'queueJobMapping' => [
                    'test_queue' => [
                        '^test_topic$' => 'TestJob',
                    ],
                    'test_queue2' => 'TestJob',
                ],
            ],

            'exchange' => [

                'name' => env('RABBITMQ_EXCHANGE_NAME'),

                'exchange_name_prefix' => env('RABBITMQ_EXCHANGE_NAME_PREFIX'),

                'routing_key_prefix' => env('RABBITMQ_ROUTING_KEY_PREFIX'),

                /*
                * Determine if exchange should be created if it does not exist.
                */
                'declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),

                //后缀为-delay的exchange也需要单独配置
                'declareMapping' => [
                    'test_exchange' => false,
                ],

                /*
                * Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
                */
                'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_TOPIC),
                'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
                'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
                'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
                'arguments' => env('RABBITMQ_EXCHANGE_ARGUMENTS'),

                //后缀为-delay的exchange也需要单独配置
                'optionsMapping' => [
                    'test_exchange' => [
                        'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_TOPIC),
                        'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
                        'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
                        'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
                        'arguments' => env('RABBITMQ_EXCHANGE_ARGUMENTS'),
                    ],
                ],
            ],

            'queue' => [

                /*
                * Determine if queue should be created if it does not exist.
                */
                'declare' => env('RABBITMQ_QUEUE_DECLARE', true),

                'declareMapping' => [
                    'test_queue' => false,
                ],

                /*
                * Determine if queue should be binded to the exchange created.
                */
                'bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true),

                //后缀为-delay的exchange也需要单独配置
                'bindMapping' => [
                    'test_queue' => [
                        'test_exchange' => [
                            'test_topic' => true,
                        ],
                    ],
                ],

                /*
                * Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
                */
                'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
                'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
                'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
                'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
                'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),

                'optionsMapping' => [
                    'test_queue' => [
                        'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
                        'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
                        'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
                        'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
                        'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),
                    ],
                ],
            ],
        ],

        /*
         * Determine the number of seconds to sleep if there's an error communicating with rabbitmq
         * If set to false, it'll throw an exception rather than doing the sleep for X seconds.
         */
        'sleep_on_error' => env('RABBITMQ_ERROR_SLEEP', false),

        /*
         * Optional SSL params if an SSL connection is used
         */
        'ssl_params' => [
            'ssl_on' => env('RABBITMQ_SSL', false),
            'cafile' => env('RABBITMQ_SSL_CAFILE', null),
            'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
            'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
            'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
            'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
        ],
    ],
    // ...
],
```

Laravel Usage
-------------

[](#laravel-usage)

Once you completed the configuration you can use Laravel Queue API. If you used other queue drivers you do not need to change anything else. If you do not know how to use Queue API, please refer to the official Laravel documentation:

Lumen Usage
-----------

[](#lumen-usage)

For Lumen usage the service provider should be registered manually as follow in `bootstrap/app.php`:

```
$app->register(VladimirYuldashev\LaravelQueueRabbitMQ\LaravelQueueRabbitMQServiceProvider::class);
```

Limitations
-----------

[](#limitations)

1. Retry command is not supported

Delay &gt; 1d (Only for Aliyun)
-------------------------------

[](#delay--1d-only-for-aliyun)

[![Delay > 1d](./docs/delay_greater_than_one_day.png)](./docs/delay_greater_than_one_day.png)

Using other AMQP transports
---------------------------

[](#using-other-amqp-transports)

The package uses [enqueue/amqp-lib](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/transport/amqp_lib.md) transport which is based on [php-amqplib](https://github.com/php-amqplib/php-amqplib). There is possibility to use any [amqp interop](https://github.com/queue-interop/queue-interop#amqp-interop) compatible transport, for example `enqueue/amqp-ext` or `enqueue/amqp-bunny`. Here's an example on how one can change the transport to `enqueue/amqp-bunny`.

First, install desired transport package:

```
composer require enqueue/amqp-bunny:^0.8
```

Change the factory class in `config/queue.php`:

```
    // ...
    'connections' => [
        'rabbitmq' => [
            'driver' => 'rabbitmq',
            'factory_class' => Enqueue\AmqpBunny\AmqpConnectionFactory::class,
        ],
    ],
```

Testing
-------

[](#testing)

Setup RabbitMQ using `docker-compose`:

```
docker-compose up -d
```

Run tests:

```
composer test
```

Contribution
------------

[](#contribution)

You can contribute to this package by discovering bugs and opening issues. Please, add to which version of package you create pull request or issue. (e.g. \[5.2\] Fatal error on delayed job)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 78.9% 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 ~53 days

Recently: every ~12 days

Total

37

Last Release

2555d ago

Major Versions

4.1 → v5.0.x-dev2016-03-14

4.2 → 5.52017-09-06

v5.5.x-dev → v6.0.02017-11-12

v6.0.3 → v7.0.02018-02-11

v7.5.0 → v8.0.02019-03-27

PHP version history (6 changes)4.0PHP &gt;=5.3.0

v5.0.x-devPHP &gt;=5.4.0

v5.2.x-devPHP &gt;=5.5.9

5.3PHP &gt;=5.6.4

5.5PHP &gt;=7.0

v7.1.0PHP ^7.1.3

### Community

Maintainers

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

---

Top Contributors

[![vyuldashev](https://avatars.githubusercontent.com/u/1809081?v=4)](https://github.com/vyuldashev "vyuldashev (240 commits)")[![makasim](https://avatars.githubusercontent.com/u/143206?v=4)](https://github.com/makasim "makasim (23 commits)")[![dustindoiron](https://avatars.githubusercontent.com/u/857244?v=4)](https://github.com/dustindoiron "dustindoiron (6 commits)")[![jlozano254](https://avatars.githubusercontent.com/u/8600559?v=4)](https://github.com/jlozano254 "jlozano254 (3 commits)")[![nicksnellockts](https://avatars.githubusercontent.com/u/15774335?v=4)](https://github.com/nicksnellockts "nicksnellockts (3 commits)")[![jinchan-ck](https://avatars.githubusercontent.com/u/3828494?v=4)](https://github.com/jinchan-ck "jinchan-ck (2 commits)")[![adm-bome](https://avatars.githubusercontent.com/u/11626777?v=4)](https://github.com/adm-bome "adm-bome (2 commits)")[![eupathy](https://avatars.githubusercontent.com/u/6639227?v=4)](https://github.com/eupathy "eupathy (2 commits)")[![hex7c0](https://avatars.githubusercontent.com/u/4419146?v=4)](https://github.com/hex7c0 "hex7c0 (2 commits)")[![AaronJan](https://avatars.githubusercontent.com/u/4630940?v=4)](https://github.com/AaronJan "AaronJan (2 commits)")[![net53](https://avatars.githubusercontent.com/u/34511399?v=4)](https://github.com/net53 "net53 (2 commits)")[![nifrasismail](https://avatars.githubusercontent.com/u/6188636?v=4)](https://github.com/nifrasismail "nifrasismail (2 commits)")[![vrubim](https://avatars.githubusercontent.com/u/127127950?v=4)](https://github.com/vrubim "vrubim (2 commits)")[![pdscopes](https://avatars.githubusercontent.com/u/13329586?v=4)](https://github.com/pdscopes "pdscopes (1 commits)")[![ConnorVG](https://avatars.githubusercontent.com/u/3260091?v=4)](https://github.com/ConnorVG "ConnorVG (1 commits)")[![jowy](https://avatars.githubusercontent.com/u/391324?v=4)](https://github.com/jowy "jowy (1 commits)")[![clanth](https://avatars.githubusercontent.com/u/17596953?v=4)](https://github.com/clanth "clanth (1 commits)")[![mikanoz](https://avatars.githubusercontent.com/u/2713277?v=4)](https://github.com/mikanoz "mikanoz (1 commits)")[![mintopia](https://avatars.githubusercontent.com/u/105940?v=4)](https://github.com/mintopia "mintopia (1 commits)")[![vladkucherov](https://avatars.githubusercontent.com/u/4151984?v=4)](https://github.com/vladkucherov "vladkucherov (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/luoxiaojun-laravel-queue-rabbitmq/health.svg)

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

###  Alternatives

[illuminate/queue

The Illuminate Queue package.

20331.4M1.2k](/packages/illuminate-queue)[palpalani/laravel-sqs-queue-json-reader

Custom SQS queue reader for Laravel

26109.8k](/packages/palpalani-laravel-sqs-queue-json-reader)[rapidez/core

Rapidez Core

1820.7k53](/packages/rapidez-core)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)[aplr/kafkaesk

Laravel Kafka queue driver

102.1k](/packages/aplr-kafkaesk)

PHPackages © 2026

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