Search code examples
rabbitmqamqplaravel-5.1

RbbitMQ in LARAVEL5.1 :: handle method of the job class is called without processed by the queue?


RABBITMQ connection settings in laravel5.1

'rabbitmq' => [
                'driver'          => 'rabbitmq',

                '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_ABUSE_SCRIPT','abuse'), // name of the default queue,

                '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' => [
                        'type'        => env('RABBITMQ_EXCHANGE_TYPE', 'direct'), 
                        '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),
                ],

        ],  

Code to push job into queue

$job = (new AddIp());  
$this->dispatch($job);  
//handle method body
public function handle()
{  
    $testQueue = new TestQueue();   
    $testQueue->process_order= '1';         
    $testQueue->save();
}  

Starting listner

php artisan queue:listen rabbitmq  

Whenever i am trying to add job into queue its handle method called without processed by queue,even i don't seen any message in queue listener window so i kindly request u what exactly happening here that i couldn't know ????


Solution

  • 1) Run composer update
    2) And re-configured https://github.com/fintech-fab/laravel-queue-rabbitmq
    3) Doing above two it works.