withLimitedHistory example

$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($envelopenew 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. */
Home | Imprint | This part of the site doesn't use cookies.