8000 Revert "Respect isRetryable decision of the retry strategy for re-delivery" by bendavies · Pull Request #50655 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Revert "Respect isRetryable decision of the retry strategy for re-delivery" #50655

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
Jun 21, 2023
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
Revert "[Messenger] Respect isRetryable decision of the retry strat…
…egy when deciding if failed message should be re-delivered"

This reverts commit 8fc3dcc.
  • Loading branch information
bendavies committed Jun 14, 2023
commit dd328a230ff4ce0039ffc22f111072c93d91bf10
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ public static function getSubscribedEvents()

private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInterface $retryStrategy): bool
{
$isRetryable = $retryStrategy->isRetryable($envelope, $e);
if ($isRetryable && $e instanceof RecoverableExceptionInterface) {
if ($e instanceof RecoverableExceptionInterface) {
return true;
}

Expand All @@ -133,7 +132,7 @@ private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInt
if ($e instanceof HandlerFailedException) {
$shouldNotRetry = true;
foreach ($e->getNestedExceptions() as $nestedException) {
if ($isRetryable && $nestedException instanceof RecoverableExceptionInterface) {
if ($nestedException instanceof RecoverableExceptionInterface) {
return true;
}

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

return $isRetryable;
return $retryStrategy->isRetryable($envelope, $e);
}

private function getRetryStrategyForTransport(string $alias): ?RetryStrategyInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testRecoverableStrategyCausesRetry()
$senderLocator->expects($this->once())->method('has')->willReturn(true);
$senderLocator->expects($this->once())->method('get')->willReturn($sender);
$retryStategy = $this->createMock(RetryStrategyInterface::class);
$retryStategy->expects($this->once())->method('isRetryable')->willReturn(true);
$retryStategy->expects($this->never())->method('isRetryable');
$retryStategy->expects($this->once())->method('getWaitingTime')->willReturn(1000);
$retryStrategyLocator = $this->createMock(ContainerInterface::class);
$retryStrategyLocator->expects($this->once())->method('has')->willReturn(true);
Expand All @@ -78,27 +78,6 @@ public function testRecoverableStrategyCausesRetry()
$listener->onMessageFailed($event);
}

public function testRetryIsOnlyAllowedWhenPermittedByRetryStrategy()
{
$senderLocator = $this->createMock(ContainerInterface::class);
$senderLocator->expects($this->never())->method('has');
$senderLocator->expects($this->never())->method('get');
$retryStrategy = $this->createMock(RetryStrategyInterface::class);
$retryStrategy->expects($this->once())->method('isRetryable')->willReturn(false);
$retryStrategy->expects($this->never())->method('getWaitingTime');
$retryStrategyLocator = $this->createMock(ContainerInterface::class);
$retryStrategyLocator->expects($this->once())->method('has')->willReturn(true);
$retryStrategyLocator->expects($this->once())->method('get')->willReturn($retryStrategy);

$listener = new SendFailedMessageForRetryListener($senderLocator, $retryStrategyLocator);

$exception = new RecoverableMessageHandlingException('retry');
$envelope = new Envelope(new \stdClass());
$event = new WorkerMessageFailedEvent($envelope, 'my_receiver', $exception);

$listener->onMessageFailed($event);
}

public function testEnvelopeIsSentToTransportOnRetry()
{
$exception = new \Exception('no!');
Expand Down
0