一、
- composer require vladimir-yuldashev/laravel-queue-rabbitmq:5.2
- composer update
二、
在config/app.php
文件中,providers
数组中添加
- VladimirYuldashevLaravelQueueRabbitMQLaravelQueueRabbitMQServiceProvider::class,
三、
1 //在app/config/queue.php文件中,connections数组中添加 2 3 'rabbitmq' => [ 4 'driver' => 'rabbitmq', 5 6 'host' => env('RABBITMQ_HOST', '127.0.0.1'), 7 'port' => env('RABBITMQ_PORT', 5672), 8 9 'vhost' => env('RABBITMQ_VHOST', '/'), 10 'login' => env('RABBITMQ_LOGIN', 'guest'), 11 'password' => env('RABBITMQ_PASSWORD', 'guest'), 12 13 'queue' => env('RABBITMQ_QUEUE'), // name of the default queue, 14 15 'exchange_declare' => env('RABBITMQ_EXCHANGE_DECLARE', true), // create the exchange if not exists 16 'queue_declare_bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true), // create the queue if not exists and bind to the exchange 17 18 'queue_params' => [ 19 'passive' => env('RABBITMQ_QUEUE_PASSIVE', false), 20 'durable' => env('RABBITMQ_QUEUE_DURABLE', true), 21 'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false), 22 'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false), 23 ], 24 25 'exchange_params' => [ 26 'name' => env('RABBITMQ_EXCHANGE_NAME', null), 27 'type' => env('RABBITMQ_EXCHANGE_TYPE', 'direct'), // more info at http://www.rabbitmq.com/tutorials/amqp-concepts.html 28 'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false), 29 'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true), // the exchange will survive server restarts 30 'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false), 31 ], 32 33 ],
四、在.env
中添加
1 QUEUE_DRIVER=rabbitmq 2 3 RABBITMQ_HOST=127.0.0.1 4 RABBITMQ_PORT=5672 5 RABBITMQ_VHOST=/ 6 RABBITMQ_LOGIN=admin 7 RABBITMQ_PASSWORD=admin 8 RABBITMQ_QUEUE=queue_name
更改参数为: