PHPackages                             freyo/laravel-queue-rocketmq - 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. freyo/laravel-queue-rocketmq

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

freyo/laravel-queue-rocketmq
============================

Queue Adapter for AlibabaMQ(Apache RocketMQ) SDK

1.0.1(5y ago)171448[2 issues](https://github.com/freyo/laravel-queue-rocketmq/issues)MITPHPPHP &gt;=5.6.4

Since Jan 9Pushed 5y ago1 watchersCompare

[ Source](https://github.com/freyo/laravel-queue-rocketmq)[ Packagist](https://packagist.org/packages/freyo/laravel-queue-rocketmq)[ RSS](/packages/freyo-laravel-queue-rocketmq/feed)WikiDiscussions master Synced yesterday

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

 [![](https://camo.githubusercontent.com/e2c95cab893e81405a7960160e0941c8820706e23ccafadbd6eb159aa516a4e4/68747470733a2f2f696d672e616c6963646e2e636f6d2f7466732f5442314454684b525858585858612e5870585858585858585858582d3230302d3230302e706e67)](https://camo.githubusercontent.com/e2c95cab893e81405a7960160e0941c8820706e23ccafadbd6eb159aa516a4e4/68747470733a2f2f696d672e616c6963646e2e636f6d2f7466732f5442314454684b525858585858612e5870585858585858585858582d3230302d3230302e706e67)

AlibabaMQ(Apache RocketMQ) Driver for Laravel Queue

 [ ![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265) ](LICENSE) [ ![Build Status](https://camo.githubusercontent.com/740aae4d09e563d45b52388a41fc81931e7f1a93341951b0e9e7c34bf628bed0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f667265796f2f6c61726176656c2d71756575652d726f636b65746d712f6d61737465722e7376673f7374796c653d666c61742d737175617265) ](https://travis-ci.org/freyo/laravel-queue-rocketmq) [ ![Coverage Status](https://camo.githubusercontent.com/9767e2de4b950f73f914edd4a80c534813fff29f137d590fa15ed4389907d037/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f667265796f2f6c61726176656c2d71756575652d726f636b65746d712e7376673f7374796c653d666c61742d737175617265) ](https://scrutinizer-ci.com/g/freyo/laravel-queue-rocketmq) [ ![Quality Score](https://camo.githubusercontent.com/868b00eefdc4e54776960d484bdc4b0f109e9c4ffbe194266797e15a27b84eb9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f667265796f2f6c61726176656c2d71756575652d726f636b65746d712e7376673f7374796c653d666c61742d737175617265) ](https://scrutinizer-ci.com/g/freyo/laravel-queue-rocketmq) [ ![Packagist Version](https://camo.githubusercontent.com/6f845c21260724034ffd4d84884a4c34326e948b57ec81400883ae10dbae8683/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f667265796f2f6c61726176656c2d71756575652d726f636b65746d712e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/freyo/laravel-queue-rocketmq) [ ![Total Downloads](https://camo.githubusercontent.com/7f4ea32529eed819fb045cea8ae0bd0afac9e191ffe250893458aa019b0c14b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f667265796f2f6c61726176656c2d71756575652d726f636b65746d712e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/freyo/laravel-queue-rocketmq)

 [ ![FOSSA Status](https://camo.githubusercontent.com/b0d3cb7acf54890723afbb46f36e81e4c8a0098b6b4c68b55f0683c360e7f088/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d253246667265796f2532466c61726176656c2d71756575652d726f636b65746d712e7376673f747970653d736d616c6c) ](https://app.fossa.io/projects/git%2Bgithub.com%2Ffreyo%2Flaravel-queue-rocketmq?ref=badge_small)

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

[](#installation)

```
composer require freyo/laravel-queue-rocketmq
```

Configure
---------

[](#configure)

**Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.**

1. `config/app.php`:

```
'providers' => [
  // ...
  Freyo\LaravelQueueRocketMQ\LaravelQueueRocketMQServiceProvider::class,
]
```

2. `.env`:

```
QUEUE_DRIVER=rocketmq

ROCKETMQ_ACCESS_KEY=your-access-key
ROCKETMQ_ACCESS_ID=your-access-id

ROCKETMQ_ENDPOINT=http://***.mqrest.***.aliyuncs.com
ROCKETMQ_INSTANCE_ID=MQ_INST_***_***
ROCKETMQ_GROUP_ID=GID_***

ROCKETMQ_QUEUE=topic_name # default topic name

ROCKETMQ_USE_MESSAGE_TAG=false # set to true to use message tag
ROCKETMQ_WAIT_SECONDS=0

```

Usage
-----

[](#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:

### Example

[](#example)

#### Dispatch Jobs

[](#dispatch-jobs)

The default connection name is `rocketmq`

```
// Without message tag (ROCKETMQ_USE_MESSAGE_TAG=false)
Job::dispatch()->onConnection('connection-name')->onQueue('TopicTestMQ');
// or dispatch((new Job())->onConnection('connection-name')->onQueue('TopicTestMQ'))

// With message tag (ROCKETMQ_USE_MESSAGE_TAG=true)
Job::dispatch()->onConnection('connection-name')->onQueue('TagA');
// or dispatch((new Job())->onConnection('connection-name')->onQueue('TagA'))
```

#### Multiple Queues

[](#multiple-queues)

Configure `config/queue.php`

```
'connections' => [
    //...
    'new-connection-name' => [
        'driver' => 'rocketmq',
        'access_key' => 'your-access-key',
        'access_id'  => 'your-access-id',
        'endpoint' => 'http://***.mqrest.***.aliyuncs.com',
        'instance_id' => 'MQ_INST_***_***',
        'group_id' => 'GID_***',
        'queue' => 'your-default-topic-name',
        'use_message_tag' => false,
        'wait_seconds' => 0,
        'plain' => [
            'enable' => false,
            'job' => 'App\Jobs\RocketMQPlainJobHandler@handle',
        ],
    ];
    //...
];
```

#### Process Jobs

[](#process-jobs)

```
php artisan queue:work {connection-name} --queue={queue-name}
```

#### Plain Mode

[](#plain-mode)

Configure `.env`

```
ROCKETMQ_PLAIN_ENABLE=true
ROCKETMQ_PLAIN_JOB=App\Jobs\RocketMQPlainJob@handle

```

Create a job implements `PlainPayload` interface. The method `getPayload` must return a sting value.

```
