Skip to content

Commit 10bfa22

Browse files
committed
Deprecate option prefetch_count
1 parent 7d3e54f commit 10bfa22

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.3.0
5+
-----
6+
7+
* Deprecated the `prefetch_count` parameter, it has no effect and will be removed in Symfony 6.0.
8+
49
5.2.0
510
-----
611

Tests/Transport/ConnectionTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,9 @@ public function testItSetupQueuesOnce()
439439
$connection->publish('body');
440440
}
441441

442+
/**
443+
* @group legacy
444+
*/
442445
public function testSetChannelPrefetchWhenSetup()
443446
{
444447
$factory = new TestAmqpFactory(
@@ -451,11 +454,11 @@ public function testSetChannelPrefetchWhenSetup()
451454
// makes sure the channel looks connected, so it's not re-created
452455
$amqpChannel->expects($this->any())->method('isConnected')->willReturn(true);
453456

454-
$amqpChannel->expects($this->exactly(2))->method('setPrefetchCount')->with(2);
457+
$amqpChannel->expects($this->never())->method('setPrefetchCount');
458+
459+
$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.');
455460
$connection = Connection::fromDsn('amqp://localhost?prefetch_count=2', [], $factory);
456461
$connection->setup();
457-
$connection = Connection::fromDsn('amqp://localhost', ['prefetch_count' => 2], $factory);
458-
$connection->setup();
459462
}
460463

461464
public function testAutoSetupWithDelayDeclaresExchangeQueuesAndDelay()

Transport/Connection.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ public function __construct(array $connectionOptions, array $exchangeOptions, ar
149149
* * queue_name_pattern: Pattern to use to create the queues (Default: "delay_%exchange_name%_%routing_key%_%delay%")
150150
* * exchange_name: Name of the exchange to be used for the delayed/retried messages (Default: "delays")
151151
* * auto_setup: Enable or not the auto-setup of queues and exchanges (Default: true)
152-
* * prefetch_count: set channel prefetch count
153152
*
154153
* * Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune for details):
155154
* * channel_max: Specifies highest channel number that the server permits. 0 means standard extension limit
@@ -238,6 +237,10 @@ private static function validateOptions(array $options): void
238237
trigger_deprecation('symfony/messenger', '5.1', 'Invalid option(s) "%s" passed to the AMQP Messenger transport. Passing invalid options is deprecated.', implode('", "', $invalidOptions));
239238
}
240239

240+
if (isset($options['prefetch_count'])) {
241+
trigger_deprecation('symfony/messenger', '5.3', 'The "prefetch_count" option passed to the AMQP Messenger transport has no effect and should not be used.');
242+
}
243+
241244
if (\is_array($options['queues'] ?? false)) {
242245
foreach ($options['queues'] as $queue) {
243246
if (!\is_array($queue)) {
@@ -492,10 +495,6 @@ public function channel(): \AMQPChannel
492495
}
493496
$this->amqpChannel = $this->amqpFactory->createChannel($connection);
494497

495-
if (isset($this->connectionOptions['prefetch_count'])) {
496-
$this->amqpChannel->setPrefetchCount($this->connectionOptions['prefetch_count']);
497-
}
498-
499498
if ('' !== ($this->connectionOptions['confirm_timeout'] ?? '')) {
500499
$this->amqpChannel->confirmSelect();
501500
$this->amqpChannel->setConfirmCallback(

0 commit comments

Comments
 (0)