Skip to content

[Messenger] Deprecate option prefetch_count #39660

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 1 commit into from
Jan 2, 2021
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 UPGRADE-5.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------

Expand Down
1 change: 1 addition & 0 deletions UPGRADE-6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
Expand Down
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
=========

5.3.0
-----

* Deprecated the `prefetch_count` parameter, it has no effect and will be removed in Symfony 6.0.

5.2.0
-----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ public function testItSetupQueuesOnce()
$connection->publish('body');
}

/**
* @group legacy
*/
public function testSetChannelPrefetchWhenSetup()
{
$factory = new TestAmqpFactory(
Expand All @@ -451,11 +454,11 @@ public function testSetChannelPrefetchWhenSetup()
// 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public function __construct(array $connectionOptions, array $exchangeOptions, ar
* * 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
Expand Down Expand Up @@ -238,6 +237,10 @@ private static function validateOptions(array $options): void
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)) {
Expand Down Expand Up @@ -492,10 +495,6 @@ public function channel(): \AMQPChannel
}
$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(
Expand Down