From 5b55097500bc77e3384fc06c5056fda86e821ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 29 Dec 2020 21:57:03 +0100 Subject: [PATCH] Deprecate option prefetch_count --- UPGRADE-5.3.md | 5 +++++ UPGRADE-6.0.md | 1 + src/Symfony/Component/Messenger/Bridge/Amqp/CHANGELOG.md | 5 +++++ .../Bridge/Amqp/Tests/Transport/ConnectionTest.php | 9 ++++++--- .../Messenger/Bridge/Amqp/Transport/Connection.php | 9 ++++----- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/UPGRADE-5.3.md b/UPGRADE-5.3.md index 8ba314700e..da8682aed1 100644 --- a/UPGRADE-5.3.md +++ b/UPGRADE-5.3.md @@ -23,6 +23,11 @@ HttpKernel * Marked the class `Symfony\Component\HttpKernel\EventListener\DebugHandlersListener` as internal +Messenger +--------- + +* Deprecated the `prefetch_count` parameter in the AMQP bridge, it has no effect and will be removed in Symfony 6.0. + Notifier ------- diff --git a/UPGRADE-6.0.md b/UPGRADE-6.0.md index 78124a7c53..dae5bfd4a4 100644 --- a/UPGRADE-6.0.md +++ b/UPGRADE-6.0.md @@ -112,6 +112,7 @@ Messenger * Use of invalid options in Redis and AMQP connections now throws an error. * The signature of method `RetryStrategyInterface::isRetryable()` has been updated to `RetryStrategyInterface::isRetryable(Envelope $message, \Throwable $throwable = null)`. * The signature of method `RetryStrategyInterface::getWaitingTime()` has been updated to `RetryStrategyInterface::getWaitingTime(Envelope $message, \Throwable $throwable = null)`. + * Removed the `prefetch_count` parameter in the AMQP bridge. Mime ---- diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/CHANGELOG.md b/src/Symfony/Component/Messenger/Bridge/Amqp/CHANGELOG.md index 81c0100991..f7a394efdc 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/CHANGELOG.md +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.3.0 +----- + +* Deprecated the `prefetch_count` parameter, it has no effect and will be removed in Symfony 6.0. + 5.2.0 ----- diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php index db8c5e1bb2..0d4f63ed6d 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php @@ -439,6 +439,9 @@ class ConnectionTest extends TestCase $connection->publish('body'); } + /** + * @group legacy + */ public function testSetChannelPrefetchWhenSetup() { $factory = new TestAmqpFactory( @@ -451,11 +454,11 @@ class ConnectionTest extends TestCase // makes sure the channel looks connected, so it's not re-created $amqpChannel->expects($this->any())->method('isConnected')->willReturn(true); - $amqpChannel->expects($this->exactly(2))->method('setPrefetchCount')->with(2); + $amqpChannel->expects($this->never())->method('setPrefetchCount'); + + $this->expectDeprecation('Since symfony/messenger 5.3: The "prefetch_count" option passed to the AMQP Messenger transport has no effect and should not be used.'); $connection = Connection::fromDsn('amqp://localhost?prefetch_count=2', [], $factory); $connection->setup(); - $connection = Connection::fromDsn('amqp://localhost', ['prefetch_count' => 2], $factory); - $connection->setup(); } public function testAutoSetupWithDelayDeclaresExchangeQueuesAndDelay() diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php index d48c5474c2..d2d6decf71 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php @@ -149,7 +149,6 @@ class Connection * * 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") * * auto_setup: Enable or not the auto-setup of queues and exchanges (Default: true) - * * prefetch_count: set channel prefetch count * * * Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune for details): * * channel_max: Specifies highest channel number that the server permits. 0 means standard extension limit @@ -238,6 +237,10 @@ class Connection trigger_deprecation('symfony/messenger', '5.1', 'Invalid option(s) "%s" passed to the AMQP Messenger transport. Passing invalid options is deprecated.', implode('", "', $invalidOptions)); } + if (isset($options['prefetch_count'])) { + trigger_deprecation('symfony/messenger', '5.3', 'The "prefetch_count" option passed to the AMQP Messenger transport has no effect and should not be used.'); + } + if (\is_array($options['queues'] ?? false)) { foreach ($options['queues'] as $queue) { if (!\is_array($queue)) { @@ -492,10 +495,6 @@ class Connection } $this->amqpChannel = $this->amqpFactory->createChannel($connection); - if (isset($this->connectionOptions['prefetch_count'])) { - $this->amqpChannel->setPrefetchCount($this->connectionOptions['prefetch_count']); - } - if ('' !== ($this->connectionOptions['confirm_timeout'] ?? '')) { $this->amqpChannel->confirmSelect(); $this->amqpChannel->setConfirmCallback(