RabbitMQ driver for Laravel Queue. Supports Laravel Horizon.

Overview

RabbitMQ Queue driver for Laravel

Latest Stable Version Build Status Total Downloads StyleCI License

Support Policy

Only the latest version will get new features. Bug fixes will be provided using the following scheme:

Package Version Laravel Version Bug Fixes Until
9 6 October 5th, 2021 Documentation
10 6, 7 October 5th, 2021 Documentation
11 8 April 6th, 2021 Documentation

Installation

You can install this package via composer using this command:

composer require vladimir-yuldashev/laravel-queue-rabbitmq

The package will automatically register itself.

Add connection to config/queue.php:

'connections' => [
    // ...

    'rabbitmq' => [
    
       'driver' => 'rabbitmq',
       'queue' => env('RABBITMQ_QUEUE', 'default'),
       'connection' => PhpAmqpLib\Connection\AMQPLazyConnection::class,
   
       'hosts' => [
           [
               'host' => env('RABBITMQ_HOST', '127.0.0.1'),
               'port' => env('RABBITMQ_PORT', 5672),
               'user' => env('RABBITMQ_USER', 'guest'),
               'password' => env('RABBITMQ_PASSWORD', 'guest'),
               'vhost' => env('RABBITMQ_VHOST', '/'),
           ],
       ],
   
       'options' => [
           'ssl_options' => [
               '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),
           ],
           'queue' => [
               'job' => VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob::class,
           ],
       ],
   
       /*
        * Set to "horizon" if you wish to use Laravel Horizon.
        */
       'worker' => env('RABBITMQ_WORKER', 'default'),
        
    ],

    // ...    
],

Optional Config

Optionally add queue options to the config of a connection. Every queue created for this connection, get's the properties.

When you want to prioritize messages when they were delayed, then this is possible by adding extra options.

  • When max-priority is omitted, the max priority is set with 2 when used.
'connections' => [
    // ...

    'rabbitmq' => [
        // ...

        'options' => [
            'queue' => [
                // ...

                'prioritize_delayed' =>  false,
                'queue_max_priority' => 10,
            ],
        ],
    ],

    // ...    
],

When you want to publish messages against an exchange with routing-key's, then this is possible by adding extra options.

  • When the exchange is omitted, RabbitMQ will use the amq.direct exchange for the routing-key
  • When routing-key is omitted the routing-key by default is the queue name.
  • When using %s in the routing-key the queue_name will be substituted.

Note: when using exchange with routing-key, u probably create your queues with bindings yourself.

'connections' => [
    // ...

    'rabbitmq' => [
        // ...

        'options' => [
            'queue' => [
                // ...

                'exchange' => 'application-x',
                'exchange_type' => 'topic',
                'exchange_routing_key' => '',
            ],
        ],
    ],

    // ...    
],

In Laravel failed jobs are stored into the database. But maybe you want to instruct some other process to also do something with the message. When you want to instruct RabbitMQ to reroute failed messages to a exchange or a specific queue, then this is possible by adding extra options.

  • When the exchange is omitted, RabbitMQ will use the amq.direct exchange for the routing-key
  • When routing-key is omitted, the routing-key by default the queue name is substituted with '.failed'.
  • When using %s in the routing-key the queue_name will be substituted.

Note: When using failed_job exchange with routing-key, u probably need to create your exchange/queue with bindings yourself.

'connections' => [
    // ...

    'rabbitmq' => [
        // ...

        'options' => [
            'queue' => [
                // ...

                'reroute_failed' => true,
                'failed_exchange' => 'failed-exchange',
                'failed_routing_key' => 'application-x.%s',
            ],
        ],
    ],

    // ...    
],

Use your own RabbitMQJob class

Sometimes you have to work with messages published by another application.
Those messages probably won't respect Laravel's job payload schema. The problem with these messages is that, Laravel workers won't be able to determine the actual job or class to execute.

You can extend the build-in RabbitMQJob::class and within the queue connection config, you can define your own class. When you specify an job key in the config, with your own class name, every message retrieved from the broker will get wrapped by your own class.

An example for the config:

'connections' => [
    // ...

    'rabbitmq' => [
        // ...

        'options' => [
            'queue' => [
                // ...

                'job' => \App\Queue\Jobs\RabbitMQJob::class,
            ],
        ],
    ],

    // ...    
],

An example of your own job class:

<?php

namespace App\Queue\Jobs;

use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob as BaseJob;

class RabbitMQJob extends BaseJob
{

    /**
     * Fire the job.
     *
     * @return void
     */
    public function fire()
    {
        $payload = $this->payload();

        $class = WhatheverClassNameToExecute::class;
        $method = 'handle';

        ($this->instance = $this->resolve($class))->{$method}($this, $payload);

        $this->delete();
    }
}

Or maybe you want to add extra properties to the payload:

<?php

namespace App\Queue\Jobs;

use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob as BaseJob;

class RabbitMQJob extends BaseJob
{
   /**
     * Get the decoded body of the job.
     *
     * @return array
     */
    public function payload()
    {
        return [
            'job'  => 'WhatheverFullyQualifiedClassNameToExecute@handle',
            'data' => json_decode($this->getRawBody(), true)
        ];
    }
}

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: http://laravel.com/docs/queues

Laravel Horizon Usage

Starting with 8.0, this package supports Laravel Horizon out of the box. Firstly, install Horizon and then set RABBITMQ_WORKER to horizon.

Lumen Usage

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

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

Consuming Messages

There are two ways of consuming messages.

  1. queue:work command which is Laravel's built-in command. This command utilizes basic_get.

  2. rabbitmq:consume command which is provided by this package. This command utilizes basic_consume and is more performant than basic_get by ~2x.

Testing

Setup RabbitMQ using docker-compose:

docker-compose up -d rabbitmq

To run the test suite you can use the following commands:

# To run both style and unit tests.
composer test

# To run only style tests.
composer test:style

# To run only unit tests.
composer test:unit

If you receive any errors from the style tests, you can automatically fix most, if not all of the issues with the following command:

composer fix:style

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)

Comments
  • Amqp interop based version.

    Amqp interop based version.

    ref https://github.com/vyuldashev/laravel-queue-rabbitmq/issues/153

    This is far from the final version, the aim of this PR is to show differences in approaches.

    opened by makasim 25
  • Undefined index: command

    Undefined index: command

    When I use Queued Event Listeners I get the error "Undefined index: command" when the handle() function of that event listener fails / throws an exception.

    The method release() in the class VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob expect there to be $body['data']['command'], but when using Queued Event Listeners, that is not the case, the payload is actually:

    { "job": "Illuminate\\Events\\CallQueuedHandler@call", "data": { "class": "App\\Listeners\\Frontend\\Auditfile\\AuditfileUploadedListener", "method": "handle", "data": "a:1:{i:0;O:47:\"App\\Events\\Frontend\\Auditfile\\AuditfileUploaded\":1:{s:58:\"\u0000App\\Events\\Frontend\\Auditfile\\AuditfileUploaded\u0000auditfile\";O:45:\"Illuminate\\Contracts\\Database\\ModelIdentifier\":2:{s:5:\"class\";s:30:\"App\\Models\\Auditfile\\Auditfile\";s:2:\"id\";i:4;}}}" } }

    Compare that to the payload of a normal Job: {"job":"Illuminate\\Queue\\CallQueuedHandler@call","data":{"commandName":"App\\Jobs\\ImportAuditfileJob","command":"O:27:\"App\\Jobs\\ImportAuditfileJob\":5:{s:38:\"\u0000App\\Jobs\\ImportAuditfileJob\u0000auditfile\";O:45:\"Illuminate\\Contracts\\Database\\ModelIdentifier\":2:{s:5:\"class\";s:30:\"App\\Models\\Auditfile\\Auditfile\";s:2:\"id\";i:9;}s:10:\"connection\";N;s:5:\"queue\";N;s:5:\"delay\";N;s:6:\"\u0000*\u0000job\";N;}"}}

    I hope this is enough information

    opened by rdrenth 24
  • Queue listener enters an endless loop error state when dispatching a delayed job

    Queue listener enters an endless loop error state when dispatching a delayed job

    • Laravel/Lumen version: 6.3.3
    • RabbitMQ version: 3.8.6 (I think)
    • Package version: 10.2.2

    Describe the bug

    The connection or channel seems to get closed when dispatching a delayed job, leading to a cascade of issues that result in a listener running into an endless loop of error messages.

    Steps To Reproduce

    A running job dispatches another job with a delay.

    Current behavior

    First I get an ACCESS_DENIED exception, then an endless loop of AMQPChannelClosedException exceptions. The job and lister do not exit, but enter this endless loop state.

    Expected behavior

    A job should be dispatched.

    Additional context

    The lost connection or channel, resulting in the ACCESS_DENIED error can be reproducred in artisan tinker. With some class names changed, it looks like this:

    >>> $j = new App\Jobs\TestJob()
    => App\Jobs\TestJob {#3155
         +connection: null,
         +queue: null,
         +chainConnection: null,
         +chainQueue: null,
         +delay: null,
         +middleware: [],
         +chained: [],
       }
    >>> dispatch($j->delay(Carbon\Carbon::now()->addSeconds(50)))
    => Laravel\Lumen\Bus\PendingDispatch {#3156}
    >>> DB::commit()
    => null
    
    Then the same again in the same tinker session:
    
    >>> $j = new App\Jobs\TestJob()
    => App\Jobs\TestJob {#3198
         +connection: null,
         +queue: null,
         +chainConnection: null,
         +chainQueue: null,
         +delay: null,
         +middleware: [],
         +chained: [],
       }
    >>> dispatch($j->delay(Carbon\Carbon::now()->addSeconds(50)))
    => Laravel\Lumen\Bus\PendingDispatch {#3199}
    >>> DB::commit()
    PhpAmqpLib/Exception/AMQPProtocolChannelException with message 'ACCESS_REFUSED - access to exchange 'amq.default' in vhost 'myhost' refused for user 'myuser''
    

    Notes:

    • We build all the queues in advance.
    • Our default queue is jobs.default.
    • In the first instance above a queue is correctly created called jobs.default.delay.48000.
    • I do NOT see the job added to the delay queue - no jobs appear to go through it.
    • The user myuser does not have permission to use exchange amq.default and I don't know why it is trying to do so.
    • The error appears to come from the creation of the delay queue the second time (it does get created the first time, but the second run through does not seem to see it).
    • With debug turned on, I see the connection created right at the start, but do not see the connection close being logged until we get to the ACCESS_DENIED point - I think you have an aoption authentication_failure_close=1 set for the connection, so I can see why it all goes wrong after that.
    opened by judgej 23
  • Target class [] does not exist - BindingResolutionException  - queue messages get consumed - job seems to fail

    Target class [] does not exist - BindingResolutionException - queue messages get consumed - job seems to fail

    Laravel Version: 6.7.0 Package Version: 9.0 RabbitMQ Version: 3.8.2

    Describe the bug The queue seems to be executed correctly but when I run php artisan queue:work but:

    1. the terminal displays:

    [2019-12-16 15:36:31][] Processing: [2019-12-16 15:36:31][] Failed:

    1. The output in the laravel logs is: local.ERROR: Target class [] does not exist. {"exception":"[object] (Illuminate\Contracts\Container\BindingResolutionException(code: 0): Target class [] does not exist. at /vendor/laravel/framework/src/Illuminate/Container/Container.php:805) [stacktrace]

    2. In addition the failed_jobs table gets filled with the current job error and so, even if I can log the queue body of the message and the message seems consumed and Acked in the queue-end the job seems as failed eventually.

    3. This happens for the default worker as well as a custom one I created which extends the VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue class (needed to change the connect method and replace "instanceof" with "is_subclass_of" as suggested in https://github.com/vyuldashev/laravel-queue-rabbitmq/pull/247)

    In any case, even if I leave the connector untouched and use the default worker the result is the same...

    Note that this does not happen when I dispatch the job but only for the artisan queue:work

    connection configuration 'rabbitmq' => [

            'driver' => 'rabbitmq',
    
            /*
             * Set to "horizon" if you wish to use Laravel Horizon.
             */
            'worker' =>  'worker' => env('RABBITMQ_WORKER', 'default'),,
    
            'dsn' => env('RABBITMQ_DSN', null),
    
            'factory_class' => Enqueue\AmqpLib\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'),
    
            'queue' => env('RABBITMQ_QUEUE', 'default'),
    
            'options' => [
    
                'exchange' => [
    
                    'name' => env('RABBITMQ_EXCHANGE_NAME'),
    
                    'declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),
    
                    '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' => [
    
                    'declare' => env('RABBITMQ_QUEUE_DECLARE', true),
    
                    'bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true),
    
                    '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'),
                ],
            ]
    

    Queue Details The type of the queue is "topic". The queue is running in the local machine, while the test application lives inside the Homestead VM. Thus, to access the queue the url needs to be 10.0.2.2.

    env configuration options RABBITMQ_HOST=10.0.2.2 RABBITMQ_QUEUE=q.user.created RABBITMQ_EXCHANGE_NAME=user.created

    I would appreciate your help..

    P.S.:Thank you @vyuldashev et all for your efforts.

    opened by johnnemo 17
  • Undefined index: job

    Undefined index: job

    exception 'ErrorException' with message 'Undefined index: job' in /var/www/api-v1.gdmfx.com/httpdocs/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/VladimirYuldashev/LaravelQueueRabbitMQ/Queue/Jobs/RabbitMQJob.php:96

    got too many of this errors, got same when used redis as queue, but on laravel site developers told that it can be in case of cross match between cache and queue jobs. What the problem is here maybe laravel side again?

    I used this versions "laravel/framework": "5.1.*", "vladimir-yuldashev/laravel-queue-rabbitmq": "5.1",

    Thanks!

    opened by Borkache 17
  • Exception: no connector for [rabbitmq]

    Exception: no connector for [rabbitmq]

    Hi there

    Apologies for this issue, I'm sure it's something I'm doing wrong. I have installed and configured the package, and with my default driver set to sync (or anything other than rabbitmq), my app boots fine:

    vagrant@homestead:~/repos/gk$ php artisan tinker
    Psy Shell v0.5.2 (PHP 5.6.10-1+deb.sury.org~trusty+1 — cli) by Justin Hileman
    >>> $q = app('queue');
    => Illuminate\Queue\QueueManager {#182}
    >>> $con = $q->connection('rabbitmq');
    => FintechFab\LaravelQueueRabbitMQ\Queue\RabbitMQQueue {#779
         +"crypt": Illuminate\Encryption\McryptEncrypter {#191},
       }
    >>>
    

    But as soon as I set 'default' => 'rabbitmq', I get exceptions:

    vagrant@homestead:~/repos/gk$ php artisan
    
    
    
      [InvalidArgumentException]
      No connector for [rabbitmq]
    
    
    
    vagrant@homestead:~/repos/gk$
    

    The only think I can think of is that the rabbitmq driver isn't available until the application has fully booted, but I'm not sure why that would be the case. The docs for this package suggest you can set QUEUE_DRIVER=rabbitmq in your .env file so I guess in theory I should be able to use it as my default driver. Any suggestions? (using L5.1)

    opened by opb 16
  • Version 7.4 can't work on lumen 5.6

    Version 7.4 can't work on lumen 5.6

    When run php artisan queue:work

    In RabbitMQQueue.php line 17:
                                                                                   
      Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue::  
      createPayloadArray($job, $queue, $data = '') should be compatible with Illu  
      minate\Queue\Queue::createPayloadArray($job, $data = '')
    
    bug 
    opened by thaibinhindex 14
  • Allow laravel to end workers with lost connection

    Allow laravel to end workers with lost connection

    Exception thrown by ::pop is checked by Illuminate\Database\DetectsLostConnections::causedByLostConnection It should throw exception with special message in order to end queue on error correctly. Otherwise it continues to work with broken connection.

    https://github.com/vyuldashev/laravel-queue-rabbitmq/issues/421 https://github.com/vyuldashev/laravel-queue-rabbitmq/issues/436

    opened by violarium 13
  • Fixing attempts incrementing:

    Fixing attempts incrementing:

    In the RabbitMQQueue.php:

    • $message was changed to a class property ($this->message)

    In the RabbitMQJob.php:

    • class const ATTEMPT_COUNT_HEADERS_KEY was changed from “attempts_count” to “attempts”
    opened by mrvtoney 13
  • Help figuring out what is going on

    Help figuring out what is going on

    AMQPExchangeException Library error: table too large for buffer

    No idea how to get into the problem. It is coming from rabbitmq-c

    Any suggestion would be appreciated

    opened by mkumara 13
  • Message lost when publishing to a delayed queue

    Message lost when publishing to a delayed queue

    • Laravel/Lumen version: 7.15.0
    • RabbitMQ version: 3.7.17
    • Package version: 10.2.1

    Describe the bug

    When the publisher writes a message directly to a delayed queue, the message is lost because the normal queue where the dead letter redirects doesn't exist

    Steps To Reproduce

    1. Start a consumer to the queue "my-messages"
    2. Send a message with a delay to the "my-messages" queue
    3. Wait until delay is over

    Current behavior

    • What happens with the worker? The message never reach the worker
    • Is the message gone? Yes, the temporary queue after the expiration time resend the message to "my-messages", but that queue doesn't exist. Just the "my-messages.delay.xxxx" exist.

    Expected behavior

    Both queues (delayed and not) should be created, so when I publish a delayed message, the worker receives it after the expiration time.

    Additional context

    This is useful when you want to start a specific process with a delay.

    question 
    opened by joskfg 12
  • vyuldashev/laravel-queue-rabbitmq  \Horizon\JobPayload not found

    vyuldashev/laravel-queue-rabbitmq \Horizon\JobPayload not found

    • Laravel/Framework: 8.75
    • RabbitMQ version: 3
    • Package version: ^11.3

    Describe the bug I've properly configured the RabbitMQ container and hooked it up to my docker network, I can connect with the dashboard and $ php artisan rabbitmq:consume works fine, but when I schedule a job it throws this exception.

    {
        "message": "Class \"Laravel\\Horizon\\JobPayload\" not found",
        "exception": "Error",
        "file": "/var/www/html/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Horizon/RabbitMQQueue.php",
        "line": 52,
        "trace": [
            {
                "file": "/var/www/html/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Queue/RabbitMQQueue.php",
                "line": 125,
                "function": "pushRaw",
                "class": "VladimirYuldashev\\LaravelQueueRabbitMQ\\Horizon\\RabbitMQQueue",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Horizon/RabbitMQQueue.php",
                "line": 44,
                "function": "push",
                "class": "VladimirYuldashev\\LaravelQueueRabbitMQ\\Queue\\RabbitMQQueue",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php",
                "line": 253,
                "function": "push",
                "class": "VladimirYuldashev\\LaravelQueueRabbitMQ\\Horizon\\RabbitMQQueue",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php",
                "line": 229,
                "function": "pushCommandToQueue",
                "class": "Illuminate\\Bus\\Dispatcher",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php",
                "line": 77,
                "function": "dispatchToQueue",
                "class": "Illuminate\\Bus\\Dispatcher",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bus/DispatchesJobs.php",
                "line": 17,
                "function": "dispatch",
                "class": "Illuminate\\Bus\\Dispatcher",
                "type": "->"
            },
            {
                "file": "/var/www/html/app/Http/Controllers/CategoryController.php",
                "line": 59,
                "function": "dispatch",
                "class": "App\\Http\\Controllers\\Controller",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
                "line": 54,
                "function": "store",
                "class": "App\\Http\\Controllers\\CategoryController",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
                "line": 45,
                "function": "callAction",
                "class": "Illuminate\\Routing\\Controller",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
                "line": 262,
                "function": "dispatch",
                "class": "Illuminate\\Routing\\ControllerDispatcher",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
                "line": 205,
                "function": "runController",
                "class": "Illuminate\\Routing\\Route",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
                "line": 721,
                "function": "run",
                "class": "Illuminate\\Routing\\Route",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 128,
                "function": "Illuminate\\Routing\\{closure}",
                "class": "Illuminate\\Routing\\Router",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php",
                "line": 50,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 167,
                "function": "handle",
                "class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
                "line": 127,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
                "line": 103,
                "function": "handleRequest",
                "class": "Illuminate\\Routing\\Middleware\\ThrottleRequests",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
                "line": 55,
                "function": "handleRequestUsingNamedLimiter",
                "class": "Illuminate\\Routing\\Middleware\\ThrottleRequests",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 167,
                "function": "handle",
                "class": "Illuminate\\Routing\\Middleware\\ThrottleRequests",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php",
                "line": 44,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 167,
                "function": "handle",
                "class": "Illuminate\\Auth\\Middleware\\Authenticate",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 103,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
                "line": 723,
                "function": "then",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
                "line": 698,
                "function": "runRouteWithinStack",
                "class": "Illuminate\\Routing\\Router",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
                "line": 662,
                "function": "runRoute",
                "class": "Illuminate\\Routing\\Router",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
                "line": 651,
                "function": "dispatchToRoute",
                "class": "Illuminate\\Routing\\Router",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
                "line": 167,
                "function": "dispatch",
                "class": "Illuminate\\Routing\\Router",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 128,
                "function": "Illuminate\\Foundation\\Http\\{closure}",
                "class": "Illuminate\\Foundation\\Http\\Kernel",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
                "line": 21,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php",
                "line": 31,
                "function": "handle",
                "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 167,
                "function": "handle",
                "class": "Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
                "line": 21,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php",
                "line": 40,
                "function": "handle",
                "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 167,
                "function": "handle",
                "class": "Illuminate\\Foundation\\Http\\Middleware\\TrimStrings",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
                "line": 27,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 167,
                "function": "handle",
                "class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php",
                "line": 86,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 167,
                "function": "handle",
                "class": "Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/fruitcake/laravel-cors/src/HandleCors.php",
                "line": 52,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 167,
                "function": "handle",
                "class": "Fruitcake\\Cors\\HandleCors",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php",
                "line": 39,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 167,
                "function": "handle",
                "class": "Illuminate\\Http\\Middleware\\TrustProxies",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
                "line": 103,
                "function": "Illuminate\\Pipeline\\{closure}",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
                "line": 142,
                "function": "then",
                "class": "Illuminate\\Pipeline\\Pipeline",
                "type": "->"
            },
            {
                "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
                "line": 111,
                "function": "sendRequestThroughRouter",
                "class": "Illuminate\\Foundation\\Http\\Kernel",
                "type": "->"
            },
            {
                "file": "/var/www/html/public/index.php",
                "line": 52,
                "function": "handle",
                "class": "Illuminate\\Foundation\\Http\\Kernel",
                "type": "->"
            }
        ]
    }
    

    It's probably not an issue on the packages side, but I'm dumbstruck how to fix it. I cant find anything when googling for the issue so I'm hoping you've seen this one before!

    Note: this is about dispatching and queuing an internal job for Horizon to execute.

    opened by mikevandiepen 0
  • doesn't work with mongodb

    doesn't work with mongodb

    I tried the mongo db driver and it works fine, but when I try to consume it from the job I created with rabbitmq, it does not load data into mongodb and I get mongo db manager not found error.

    opened by yktibrahim 1
  • Use 'horizon' to manage queues and the configuration `delay` property is invalid

    Use 'horizon' to manage queues and the configuration `delay` property is invalid

    • Laravel/Lumen version:
    # php artisan --version
    Laravel Framework 9.41.0
    
    • RabbitMQ version:
    3.10
    
    • Package version:
    # composer show vladimir-yuldashev/laravel-queue-rabbitmq |grep versions
    versions : * v13.0.1
    

    Describe the bug Set a property public $delay = 60; in the job class, job not executing but message is being consumed and ack'ed

    The RabbitMQ message is consumed, but the task is not executed, and the status of the message in the Horizon management interface has not changed

    job file content

    <?php
    
    namespace App\Jobs\Notification;
    
    use App\Jobs\BaseJob;
    use Illuminate\Support\Facades\Log;
    
    
    /**
     * Class SystemNotification
     */
    class SystemNotification extends BaseJob
    {
        public $delay = 60;
    
        protected array $message = [];
    
        public function __construct(array $message)
        {
            $this->message = $message;    
        }
    
        public function handle(): void
        {
            Log::debug('test delay job: '.PHP_EOL.json_encode($this->message));
        }
    }
    
    

    Steps To Reproduce

    copy code and run

    Current behavior

    • What happens with the worker?
    • Is the message retried or put back into the queue? The rabbitMQ control panel sees that it has been consumed
    • Is the message acknowledged or rejected? acknowledged
    • Is the message unacked? no
    • Is the message gone? yes, For rabbitMQ, it should be consumed normally

    Expected behavior

    can run normally in Horizon

    Additional context

    Add any other context about the problem or describe the use-case.

    #449

    opened by shuqingzai 0
  • PHP Fatal error:  Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Consumer::stop($status = 0): int must be compatible with Illuminate\Queue\Worker::stop($status = 0, $options = null)

    PHP Fatal error: Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Consumer::stop($status = 0): int must be compatible with Illuminate\Queue\Worker::stop($status = 0, $options = null)

    I used command:

    composer update at laravel version 9.42

    log:

    `PHP Fatal error: Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Consumer::stop($status = 0): int must be compatible with Illuminate\Queue\Worker::stop($status = 0, $options = null) in /home/gabriel/Projekty/subjects_and_grades/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php on line 200

    Symfony\Component\ErrorHandler\Error\FatalError

    Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Consumer::stop($status = 0): int must be compatible with Illuminate\Queue\Worker::stop($status = 0, $options = null)

    at vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php:200 196▕ * 197▕ * @param int $status 198▕ * @return int 199▕ */ ➜ 200▕ public function stop($status = 0): int 201▕ { 202▕ // Tell the server you are going to stop consuming. 203▕ // It will finish up the last message and not send you any more. 204▕ $this->channel->basic_cancel($this->consumerTag, false, true);

    Whoops\Exception\ErrorException

    Declaration of VladimirYuldashev\LaravelQueueRabbitMQ\Consumer::stop($status = 0): int must be compatible with Illuminate\Queue\Worker::stop($status = 0, $options = null)

    at vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Consumer.php:200 196▕ * 197▕ * @param int $status 198▕ * @return int 199▕ */ ➜ 200▕ public function stop($status = 0): int 201▕ { 202▕ // Tell the server you are going to stop consuming. 203▕ // It will finish up the last message and not send you any more. 204▕ $this->channel->basic_cancel($this->consumerTag, false, true);

      +1 vendor frames 
    

    2 [internal]:0 Whoops\Run::handleShutdown() Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255 `

    opened by Zdanc32 21
Owner
Vladimir Yuldashev
Passionate Developer.
Vladimir Yuldashev
Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro

Supporting Enqueue Enqueue is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and

Enqueue 2.1k Dec 22, 2022
Laravel Enqueue message queue extension. Supports AMQP, Amazon SQS, Kafka, Google PubSub, Redis, STOMP, Gearman, Beanstalk and others

Laravel queue package You can use all transports built on top of queue-interop including all supported by Enqueue. It also supports extended AMQP feat

Enqueue 204 Dec 22, 2022
The most widely used PHP client for RabbitMQ

php-amqplib This library is a pure PHP implementation of the AMQP 0-9-1 protocol. It's been tested against RabbitMQ. The library was used for the PHP

php-amqplib 4.2k Jan 6, 2023
Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library

BunnyPHP Performant pure-PHP AMQP (RabbitMQ) sync/async (ReactPHP) library Requirements BunnyPHP requires PHP 7.1 and newer. Installation Add as Compo

Jakub Kulhan 641 Dec 29, 2022
PHP Library that implements several messaging patterns for RabbitMQ

Thumper Thumper is a PHP library that aims to abstract several messaging patterns that can be implemented over RabbitMQ. Inside the examples folder yo

php-amqplib 276 Nov 20, 2022
Redis repository implementation for Laravel Queue Batch

Laravel RedisBatchRepository Replaces default Illuminate\Bus\DatabaseBatchRepository with implementation based on Redis. Requirements: php 8 laravel 8

Roman Nix 5 Nov 15, 2022
Laravel Custom Queue System

Laravel Queue 1.1.0 Laravel custom queue system. Installation Use composer: composer require m-alsafadi/laravel-queue Add to .env file: LARAVEL_QUEUE_

Mohammad Al-Safadi 1 Aug 2, 2022
PHP client for beanstalkd queue

Pheanstalk Next (5) The master branch will be a WIP branch for v5 of this library until it is released. If any patches are needed in v4 they should be

null 1.9k Dec 21, 2022
PHP bindings for Tarantool Queue.

Tarantool Queue Tarantool is a NoSQL database running in a Lua application server. It integrates Lua modules, called LuaRocks. This package provides P

Tarantool PHP 62 Sep 28, 2022
PHP client for beanstalkd queue

Pheanstalk Pheanstalk is a pure PHP 7.1+ client for the beanstalkd workqueue. It has been actively developed, and used in production by many, since la

null 1.9k Dec 21, 2022
PHP-Queue: A unified front-end for different queuing backends. Includes a REST server, CLI interface and daemon runners.

A unified front-end for different queuing backends. Includes a REST server, CLI interface and daemon runners. Why PHP-Queue? Implementing a

CoderKungfu 646 Dec 30, 2022
Karaoke queue website for BEPIC-Fest

BEPIC-Karaoke This is a small project of a karaoke list for the annual BEPIC-Fest at Ulm University. You can add songs, remove them and change the ord

Tim Palm 2 Jun 8, 2022
anik/amqp wrapper for Laravel-ish frameworks

anik/laravel-amqp anik/amqp wrapper for Laravel-ish frameworks. Laravel Lumen Laravel Zero Examples Checkout the repository for example. Documentation

Syed Sirajul Islam Anik 22 Sep 7, 2022
RabbitMQ driver for ThinkPHP6 Queue.

RabbitMQ driver for ThinkPHP6 Queue.

null 2 Sep 14, 2022
A wrapper for vladimir-yuldashev RabbitMQ Queue for Laravel with Actions

RabbitMQ Actions This package its a wrapper of vladimir-yuldashev/rabbitmq-queue-laravel. Adds a new feature to produce and consume messages with Rabb

RocketsLab 3 Jul 12, 2022
Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro

Supporting Enqueue Enqueue is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and

Enqueue 2.1k Dec 22, 2022
Laravel Enqueue message queue extension. Supports AMQP, Amazon SQS, Kafka, Google PubSub, Redis, STOMP, Gearman, Beanstalk and others

Laravel queue package You can use all transports built on top of queue-interop including all supported by Enqueue. It also supports extended AMQP feat

Enqueue 204 Dec 22, 2022
PHP Kafka client is used in PHP-FPM and Swoole. PHP Kafka client supports 50 APIs, which might be one that supports the most message types ever.

longlang/phpkafka Introduction English | 简体中文 PHP Kafka client is used in PHP-FPM and Swoole. The communication protocol is based on the JSON file in

Swoole Project 235 Dec 31, 2022
Demo of how you can run your Laravel app with Docker Compose. Look at docker-compose.yml and the docker folder. The rest is just a clean Laravel + Horizon install.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Matt 5 Oct 22, 2021