laravel-queue-rabbitmq
laravel-queue-rabbitmq copied to clipboard
Laravel 6, configure arguments
This is my current configuration
....
'connections' => [
'rabbitmq' => [
'driver' => 'rabbitmq',
'worker' => env('RABBITMQ_WORKER', 'default'),
'queue' => env('RABBITMQ_QUEUE', 'default'),
'connection' => PhpAmqpLib\Connection\AMQPLazyConnection::class,
'host' => env('RABBITMQ_HOST'),
'port' => env('RABBITMQ_PORT'),
'vhost' => env('RABBITMQ_VHOST'),
'login' => env('RABBITMQ_LOGIN', 'guest'),
'password' => env('RABBITMQ_PASSWORD', 'guest'),
'options' => [
'exchange' => [
'name' => env('RABBITMQ_EXCHANGE_NAME'),
'declare' => true,
'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_DIRECT),
'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'),
],
]
]
],
....
Basically is a copy-paste from the example, now I want to add arguments to my queue
and my arguments
I tried with a array
'queue' => [
'arguments' => [
'x-message-ttl' => 6000
]
]
But this give the error
json_decode() expects parameter 1 to be string, array given {"exception":"[object] (ErrorException(code: 0): json_decode() expects parameter 1 to be string, array given at /var/www/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Queue/RabbitMQQueue.php:41)
So I decided to set it as string
'queue' => [
'arguments' => 'x-message-ttl:6000'
]
But this error
Argument 1 passed to Interop\Amqp\Impl\AmqpQueue::setArguments() must be of the type array, null given, called in /var/www/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Queue/RabbitMQQueue.php on line 234 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Argument 1 passed to Interop\\Amqp\\Impl\\AmqpQueue::setArguments() must be of the type array, null given, called in /var/www/vendor/vladimir-yuldashev/laravel-queue-rabbitmq/src/Queue/RabbitMQQueue.php on line 234 at /var/www/vendor/queue-interop/amqp-interop/src/Impl/AmqpQueue.php:78)
Also I want to know how can I add arguments to my queue when dispatching job
PingJob::dispatch()->onQueue("my_second_queue");
// I want to use more than one queue, that's why I use onQueue
@thewasta Have you found any solution?
I'm looking for something similar. I'd like to dispatch a job, but also copy the payload to another queue.
Fanout exchange seems to be the best, but not sure how to route.
@thewasta Have you found any solution?
I'm looking for something similar. I'd like to dispatch a job, but also copy the payload to another queue.
Fanout exchange seems to be the best, but not sure how to route.
Yes! I got it, you must to use json_encode(["argument" => "value"])
Closing due to inactivity.