Skip to content

Commit 66fb457

Browse files
author
Ratko Rudic
committed
Moves queue arguments decoding from config to RabbitMQQueue constructor. JSON decoding doesn't seem right to be in the config file.
1 parent c1fbbb9 commit 66fb457

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

config/rabbitmq.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
4040
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
4141
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
42-
'arguments' => json_decode(env('RABBITMQ_QUEUE_ARGUMENTS', '{}'), 1),
42+
'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS', null),
4343
],
4444
'exchange_params' => [
4545
'name' => env('RABBITMQ_EXCHANGE_NAME', null),

src/Queue/RabbitMQQueue.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class RabbitMQQueue extends Queue implements QueueContract
3333

3434
protected $defaultQueue;
3535
protected $configQueue;
36+
protected $configQueueArguments;
3637
protected $configExchange;
3738

3839
/**
@@ -54,6 +55,7 @@ public function __construct(AMQPStreamConnection $amqpConnection, $config)
5455
$this->connection = $amqpConnection;
5556
$this->defaultQueue = $config['queue'];
5657
$this->configQueue = $config['queue_params'];
58+
$this->configQueueArguments = json_decode($this->configQueue['arguments'], 1) ?: [];
5759
$this->configExchange = $config['exchange_params'];
5860
$this->declareExchange = $config['exchange_declare'];
5961
$this->declareBindQueue = $config['queue_declare_bind'];
@@ -231,7 +233,7 @@ private function declareQueue($name)
231233
$this->configQueue['exclusive'],
232234
$this->configQueue['auto_delete'],
233235
false,
234-
new AMQPTable($this->configQueue['arguments'])
236+
new AMQPTable($this->configQueueArguments)
235237
);
236238

237239
// bind queue to the exchange
@@ -274,7 +276,7 @@ private function declareDelayedQueue($destination, $delay)
274276
'x-dead-letter-exchange' => $destinationExchange,
275277
'x-dead-letter-routing-key' => $destination,
276278
'x-message-ttl' => $delay * 1000,
277-
], (array)$this->configQueue['arguments']);
279+
], (array)$this->configQueueArguments);
278280

279281
$this->channel->queue_declare(
280282
$name,

tests/RabbitMQConnectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function test_connect()
2525
'durable' => true,
2626
'exclusive' => false,
2727
'auto_delete' => false,
28-
'arguments' => [],
28+
'arguments' => null,
2929
],
3030
'exchange_params' => [
3131
'name' => null,

tests/RabbitMQQueueTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function setUp()
3232
'durable' => true,
3333
'exclusive' => false,
3434
'auto_delete' => false,
35-
'arguments' => [],
35+
'arguments' => null,
3636
],
3737
'exchange_params' => [
3838
'name' => 'exchange_name',

0 commit comments

Comments
 (0)