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

Skip to content

Commit ee6639f

Browse files
committed
Deprecate option prefetch_count
1 parent e905b8d commit ee6639f

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
@@ -421,6 +421,9 @@ public function testItCanDisableTheSetup()
421421
$connection->publish('body');
422422
}
423423

424+
/**
425+
* @group legacy
426+
*/
424427
public function testSetChannelPrefetchWhenSetup()
425428
{
426429
$factory = new TestAmqpFactory(
@@ -433,11 +436,11 @@ public function testSetChannelPrefetchWhenSetup()
433436
// makes sure the channel looks connected, so it's not re-created
434437
$amqpChannel->expects($this->any())->method('isConnected')->willReturn(true);
435438

436-
$amqpChannel->expects($this->exactly(2))->method('setPrefetchCount')->with(2);
439+
$amqpChannel->expects($this->never())->method('setPrefetchCount');
440+
441+
$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.');
437442
$connection = Connection::fromDsn('amqp://localhost?prefetch_count=2', [], $factory);
438443
$connection->setup();
439-
$connection = Connection::fromDsn('amqp://localhost', ['prefetch_count' => 2], $factory);
440-
$connection->setup();
441444
}
442445

443446
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
@@ -146,7 +146,6 @@ public function __construct(array $connectionOptions, array $exchangeOptions, ar
146146
* * queue_name_pattern: Pattern to use to create the queues (Default: "delay_%exchange_name%_%routing_key%_%delay%")
147147
* * exchange_name: Name of the exchange to be used for the delayed/retried messages (Default: "delays")
148148
* * auto_setup: Enable or not the auto-setup of queues and exchanges (Default: true)
149-
* * prefetch_count: set channel prefetch count
150149
*
151150
* * Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune for details):
152151
* * channel_max: Specifies highest channel number that the server permits. 0 means standard extension limit
@@ -232,6 +231,10 @@ private static function validateOptions(array $options): void
232231
trigger_deprecation('symfony/messenger', '5.1', 'Invalid option(s) "%s" passed to the AMQP Messenger transport. Passing invalid options is deprecated.', implode('", "', $invalidOptions));
233232
}
234233

234+
if (isset($options['prefetch_count'])) {
235+
trigger_deprecation('symfony/messenger', '5.3', 'The "prefetch_count" option passed to the AMQP Messenger transport has no effect and should not be used.');
236+
}
237+
235238
if (\is_array($options['queues'] ?? false)) {
236239
foreach ($options['queues'] as $queue) {
237240
if (!\is_array($queue)) {
@@ -493,10 +496,6 @@ public function channel(): \AMQPChannel
493496
}
494497
$this->amqpChannel = $this->amqpFactory->createChannel($connection);
495498

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

0 commit comments

Comments
 (0)