$delay =
$retryStrategy->
getWaitingTime($envelope,
$throwable);
$this->logger?->
warning('Error thrown while handling message {class}. Sending for retry #{retryCount} using {delay} ms delay. Error: "{error}"',
$context +
['retryCount' =>
$retryCount, 'delay' =>
$delay, 'error' =>
$throwable->
getMessage(), 'exception' =>
$throwable]);
// add the delay and retry stamp info
$retryEnvelope =
$this->
withLimitedHistory($envelope,
new DelayStamp($delay),
new RedeliveryStamp($retryCount));
// re-send the message for retry
$this->
getSenderForTransport($event->
getReceiverName())->
send($retryEnvelope);
$this->eventDispatcher?->
dispatch(new WorkerMessageRetriedEvent($retryEnvelope,
$event->
getReceiverName()));
} else { $this->logger?->
critical('Error thrown while handling message {class}. Removing from transport after {retryCount} retries. Error: "{error}"',
$context +
['retryCount' =>
$retryCount, 'error' =>
$throwable->
getMessage(), 'exception' =>
$throwable]);
} } /**
* Adds stamps to the envelope by keeping only the First + Last N stamps.
*/
private function withLimitedHistory(Envelope
$envelope, StampInterface ...
$stamps): Envelope
{ foreach ($stamps as $stamp) {