$throwable =
$event->
getThrowable();
$message =
$envelope->
getMessage();
$context =
[ 'class' =>
$message::
class,
];
$shouldRetry =
$retryStrategy &&
$this->
shouldRetry($throwable,
$envelope,
$retryStrategy);
$retryCount = RedeliveryStamp::
getRetryCountFromEnvelope($envelope);
if ($shouldRetry) { $event->
setForRetry();
++
$retryCount;
$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