【发布时间】:2019-12-22 18:50:07
【问题描述】:
我正在使用 rabbitmq 为带有 package 的消息队列开发 Laravel 5.1.46 (LTS)
.env
QUEUE_DRIVER=rabbitmq
config/queue.php
'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'),
// name of the default queue,
'queue' => env('RABBITMQ_QUEUE'),
// create the exchange if not exists
'exchange_declare' => true,
// create the queue if not exists and bind to the exchange
'queue_declare_bind' => true,
'queue_params' => [
'passive' => false,
'durable' => true, // false
'exclusive' => false,
'auto_delete' => false,
],
'exchange_params' => [
// more info at http://www.rabbitmq.com/tutorials/amqp-concepts.html
'type' => env('RABBITMQ_EXCHANGE_TYPE', 'direct'),
'passive' => false,
// the exchange will survive server restarts
'durable' => true, // fakse
'auto_delete' => false,
]
我总共有 8 个队列。队列名称存储在 .env 文件中。
QUEUE_ONE=queue-one
QUEUE_TWO=queue-two
.
.
.
QUEUE_EIGHT=queue-eight
在派遣工作时,
dispatch(new Job1())->onQueue(env('QUEUE_ONE'))
队列和消息是持久的/持久的。
由于一些性能问题,我需要更改一些队列及其消息的持久性。所以,
- 5 个队列及其消息将是瞬态的(非持久性的)
- 3 个队列及其消息将是持久的
如何在 Laravel 和 rabbitmq 中实现?
注意: 我知道,我可以设置
durable = false
但它适用于所有队列,
【问题讨论】:
-
您共享的配置只定义了 1 个队列。
-
队列名称存储在 .env 文件中
-
.env文件中的队列是怎么存储的,能举个例子吗?你是如何在它们之间切换的?
-
@Reduxx 更新了我的问题。请检查
标签: laravel rabbitmq queue message-queue