10000 Revert "[Messenger] Respect `isRetryable` decision of the retry strat… · symfony/symfony@dd328a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit dd328a2

Browse files
committed
Revert "[Messenger] Respect isRetryable decision of the retry strategy when deciding if failed message should be re-delivered"
This reverts commit 8fc3dcc.
1 parent 124311a commit dd328a2

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

src/Symfony/Component/Messenger/EventListener/SendFailedMessageForRetryListener.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ public static function getSubscribedEvents()
123123

124124
private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInterface $retryStrategy): bool
125125
{
126-
$isRetryable = $retryStrategy->isRetryable($envelope, $e);
127-
if ($isRetryable && $e instanceof RecoverableExceptionInterface) {
126+
if ($e instanceof RecoverableExceptionInterface) {
128127
return true;
129128
}
130129

@@ -133,7 +132,7 @@ private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInt
133132
if ($e instanceof HandlerFailedException) {
134133
$shouldNotRetry = true;
135134
foreach ($e->getNestedExceptions() as $nestedException) {
136-
if ($isRetryable && $nestedException instanceof RecoverableExceptionInterface) {
135+
if ($nestedException instanceof RecoverableExceptionInterface) {
137136
return true;
138137
}
139138

@@ -151,7 +150,7 @@ private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInt
151150
return false;
152151
}
153152

154-
return $isRetryable;
153+
return $retryStrategy->isRetryable($envelope, $e);
155154
}
156155

157156
private function getRetryStrategyForTransport(string $alias): ?RetryStrategyInterface

src/Symfony/Component/Messenger/Tests/EventListener/SendFailedMessageForRetryListenerTest.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testRecoverableStrategyCausesRetry()
6363
$senderLocator->expects($this->once())->method('has')->willReturn(true);
6464
$senderLocator->expects($this->once())->method('get')->willReturn($sender);
6565
$retryStategy = $this->createMock(RetryStrategyInterface::class);
66-
$retryStategy->expects($this->once())->method('isRetryable')->willReturn(true);
66+
$retryStategy->expects($this->n 8000 ever())->method('isRetryable');
6767
$retryStategy->expects($this->once())->method('getWaitingTime')->willReturn(1000);
6868
$retryStrategyLocator = $this->createMock(ContainerInterface::class);
6969
$retryStrategyLocator->expects($this->once())->method('has')->willReturn(true);
@@ -78,27 +78,6 @@ public function testRecoverableStrategyCausesRetry()
7878
$listener->onMessageFailed($event);
7979
}
8080

81-
public function testRetryIsOnlyAllowedWhenPermittedByRetryStrategy()
82-
{
83-
$senderLocator = $this->createMock(ContainerInterface::class);
84-
$senderLocator->expects($this->never())->method('has');
85-
$senderLocator->expects($this->never())->method('get');
86-
$retryStrategy = $this->createMock(RetryStrategyInterface::class);
87-
$retryStrategy->expects($this->once())->method('isRetryable')->willReturn(false);
88-
$retryStrategy->expects($this->never())->method('getWaitingTime');
89-
$retryStrategyLocator = $this->createMock(ContainerInterface::class);
90-
$retryStrategyLocator->expects($this->once())->method('has')->willReturn(true);
91-
$retryStrategyLocator->expects($this->once())->method('get')->willReturn($retryStrategy);
92-
93-
$listener = new SendFailedMessageForRetryListener($senderLocator, $retryStrategyLocator);
94-
95-
$exception = new RecoverableMessageHandlingException('retry');
96-
$envelope = new Envelope(new \stdClass());
97-
$event = new WorkerMessageFailedEvent($envelope, 'my_receiver', $exception);
98-
99-
$listener->onMessageFailed($event);
100-
}
101-
10281
public function testEnvelopeIsSentToTransportOnRetry()
10382
{
10483
$exception = new \Exception('no!');

0 commit comments

Comments
 (0)
0