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

Skip to content

Commit 050bc70

Browse files
committed
Deprecate option prefetch_count
1 parent b34890a commit 050bc70

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

UPGRADE-5.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ HttpKernel
2323

2424
* Marked the class `Symfony\Component\HttpKernel\EventListener\DebugHandlersListener` as internal
2525

26+
Messenger
27+
---------
28+
29+
* Deprecated the `prefetch_count` parameter in the AMQP bridge, it has no effect and will be removed in Symfony 6.0.
30+
2631
Notifier
2732
-------
2833

UPGRADE-6.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ Messenger
112112
* Use of invalid options in Redis and AMQP connections now throws an error.
113113
* The signature of method `RetryStrategyInterface::isRetryable()` has been updated to `RetryStrategyInterface::isRetryable(Envelope $message, \Throwable $throwable = null)`.
114114
* The signature of method `RetryStrategyInterface::getWaitingTime()` has been updated to `RetryStrategyInterface::getWaitingTime(Envelope $message, \Throwable $throwable = null)`.
115+
* Removed the `prefetch_count` parameter in the AMQP bridge.
116+
115117

116118
Mime
117119
----

src/Symfony/Component/Messenger/Bridge/Amqp/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

src/Symfony/Component/Messenger/Bridge/Amqp/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()

src/Symfony/Component/Messenger/Bridge/Amqp/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)