Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger][Amqp] Add config option 'arguments' for delay queues #48603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Symfony/Component/Messenger/Bridge/Amqp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.1
---

* Add option `delay[arguments]` in the transport definition

6.0
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ public function testSetsParametersOnTheQueueAndExchange()
],
],
],
'delay' => [
'arguments' => [
'x-queue-type' => 'classic',
'x-message-deduplication' => true,
],
],
'exchange' => [
'arguments' => [
'alternate-exchange' => 'alternate',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function __construct(array $connectionOptions, array $exchangeOptions, ar
* * delay:
* * queue_name_pattern: Pattern to use to create the queues (Default: "delay_%exchange_name%_%routing_key%_%delay%")
* * exchange_name: Name of the exchange to be used for the delayed/retried messages (Default: "delays")
* * arguments: array of extra delay queue arguments (for example: ['x-queue-type' => 'classic', 'x-message-deduplication' => true,])
* * auto_setup: Enable or not the auto-setup of queues and exchanges (Default: true)
*
* * Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune for details):
Expand Down Expand Up @@ -386,7 +387,7 @@ private function createDelayQueue(int $delay, ?string $routingKey, bool $isRetry
$queue = $this->amqpFactory->createQueue($this->channel());
$queue->setName($this->getRoutingKeyForDelay($delay, $routingKey, $isRetryAttempt));
$queue->setFlags(\AMQP_DURABLE);
$queue->setArguments([
$queue->setArguments(array_merge([
'x-message-ttl' => $delay,
// delete the delay queue 10 seconds after the message expires
// publishing another message redeclares the queue which renews the lease
Expand All @@ -397,7 +398,7 @@ private function createDelayQueue(int $delay, ?string $routingKey, bool $isRetry
// after being released from to DLX, make sure the original routing key will be used
// we must use an empty string instead of null for the argument to be picked up
'x-dead-letter-routing-key' => $routingKey ?? '',
]);
], $this->connectionOptions['delay']['arguments'] ?? []));

return $queue;
}
Expand Down