PHPackages                             vnay92/laravel-custom-queue - 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. vnay92/laravel-custom-queue

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

vnay92/laravel-custom-queue
===========================

A Queue Handler For Messages that are not Laravel Jobs. Useful while communicating between Laravel and External Systems

5.1.0(8y ago)81.5k1MITPHP

Since Apr 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/vnay92/laravel-custom-queue)[ Packagist](https://packagist.org/packages/vnay92/laravel-custom-queue)[ RSS](/packages/vnay92-laravel-custom-queue/feed)WikiDiscussions master Synced 2w ago

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

Custom Queue Handler For Laravel
================================

[](#custom-queue-handler-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/8a3ab3dfc6938b257a44e02e5d2b3ec28f5b9ba8f8d45030a7aa0d51b2b8fc02/68747470733a2f2f706f7365722e707567782e6f72672f766e617939322f6c61726176656c2d637573746f6d2d71756575652f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/vnay92/laravel-custom-queue)[![Total Downloads](https://camo.githubusercontent.com/927470137503cbb7c39811299839c0889fe05abb032974b85dc9bef67a48cae0/68747470733a2f2f706f7365722e707567782e6f72672f766e617939322f6c61726176656c2d637573746f6d2d71756575652f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/vnay92/laravel-custom-queue)[![Latest Unstable Version](https://camo.githubusercontent.com/6a071725f3b01debf865d5f20805abe02d29db441f8d05a811a5e3436a317cef/68747470733a2f2f706f7365722e707567782e6f72672f766e617939322f6c61726176656c2d637573746f6d2d71756575652f762f756e737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/vnay92/laravel-custom-queue)[![License](https://camo.githubusercontent.com/82d3e5a87e4fcfeedcd0115ed87193c435f406573dc73211eb97f16014240657/68747470733a2f2f706f7365722e707567782e6f72672f766e617939322f6c61726176656c2d637573746f6d2d71756575652f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/vnay92/laravel-custom-queue)

Laravel custom Queue Handler is a simple implementation of the laravel-esque queue handling for all queues and messages that are not part of the Laravel Framework.

There are times when your application would want to consume messages as a JSON, sent on a Queue that does not implement the Laravel Job.

This package aims to solve that use case.

Supports the same commands as Laravel, with the same parameters, with one additional Parameter:

- `custom-queue:work --handler="Class\Path\To\Handler"`
- `custom-queue:listen --handler="Class\Path\To\Handler"`
- `custom-queue:restart`

Currently Supported Queues:

- RabbitMQ

### Laravel Version Compatibility

[](#laravel-version-compatibility)

- Laravel `4.x` is not supported.
- Laravel `5.x.x` is supported from `5.1` in the respective branch.

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

[](#installation)

### Laravel 5.x

[](#laravel-5x)

Install the `vnay92/laravel-custom-queue` package:

```
$ composer require vnay92/laravel-custom-queue
```

You'll need to add the following to your `config/app.php`:

```
'providers' => array(
    // ...
    Vnay92\CustomQueue\CustomQueueServiceProvider::class,
)
```

### Configuration

[](#configuration)

Create the Custom Queue configuration file (`config/custom-queue.php`):

```
$ php artisan vendor:publish --provider="Vnay92\CustomQueue\CustomQueueServiceProvider"
```

And add these properties to `.env` with proper values:

```
CUSTOM_QUEUE_DRIVER=rabbitmq

RABBITMQ_HOST=127.0.0.1
RABBITMQ_PORT=5672
RABBITMQ_VHOST=/
RABBITMQ_LOGIN=guest
RABBITMQ_PASSWORD=guest
RABBITMQ_QUEUE=queue_name

```

The above commands and configurations are used as follows:

```
/* path/to/project/config/custom-queue.php */

return [

    /*
    |--------------------------------------------------------------------------
    | Default Queue Driver
    |--------------------------------------------------------------------------
    |
    | The API, based on the Laravel queue API supports a variety of back-ends via an unified
    | API, giving you convenient access to each back-end using the same
    | syntax for each one. Here you may set the default queue driver.
    |
    | Supported: "rabbitmq"
    |
    */

    'default' => env('CUSTOM_QUEUE_DRIVER', 'rabbitmq'),

    /*
    |--------------------------------------------------------------------------
    | Queue Connections
    |--------------------------------------------------------------------------
    |
    | Here you may configure the connection information for each server that
    | is used by your application. A default configuration has been added
    | for each back-end shipped with Laravel. You are free to add more.
    |
    */

    'connections' => [
        'rabbitmq' => [
            'driver'                => 'rabbitmq',
            'host'                  => env('RABBITMQ_HOST', 'localhost'),
            'port'                  => env('RABBITMQ_PORT', 5672),
            'vhost'                 => env('RABBITMQ_VHOST', '/'),
            'login'                 => env('RABBITMQ_LOGIN', 'guest'),
            'password'              => env('RABBITMQ_PASSWORD', 'guest'),
            'queue'                 => env('RABBITMQ_QUEUE', 'custom_default'), // name of the default queue,
            'exchange_declare'      => env('RABBITMQ_EXCHANGE_DECLARE', true), // create the exchange if not exists
            'queue_declare_bind'    => env('RABBITMQ_QUEUE_DECLARE_BIND', true), // create the queue if not exists and bind to the exchange
            'queue_params'          => [
                '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),
            ],
            'exchange_params'       => [
                'name'              => env('RABBITMQ_EXCHANGE_NAME', null),
                'type'              => env('RABBITMQ_EXCHANGE_TYPE', 'direct'), // more info at http://www.rabbitmq.com/tutorials/amqp-concepts.html
                'passive'           => env('RABBITMQ_EXCHANGE_PASSIVE', false),
                'durable'           => env('RABBITMQ_EXCHANGE_DURABLE', true), // the exchange will survive server restarts
                'auto_delete'       => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
            ],
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Failed Queue Jobs
    |--------------------------------------------------------------------------
    |
    | These options configure the behavior of failed queue job logging so you
    | can control which database and table are used to store the jobs that
    | have failed. You may change them to any database / table you wish.
    |
    */

    'failed' => [
        'database' => 'mysql', 'table' => 'failed_jobs',
    ],

];
```

Example
-------

[](#example)

Create a handler class which implements the `Vnay92\Contracts\HandlerInterface` and implement the `handle()` method.

```
