setForRetry example

$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($envelopenew DelayStamp($delay)new RedeliveryStamp($retryCount));

            // re-send the message for retry
public function testDoNothingOnRetryWithServiceLocator()
    {
        $sender = $this->createMock(SenderInterface::class);
        $sender->expects($this->never())->method('send');

        $serviceLocator = $this->createMock(ServiceLocator::class);
        $listener = new SendFailedMessageToFailureTransportListener($serviceLocator);

        $envelope = new Envelope(new \stdClass());
        $event = new WorkerMessageFailedEvent($envelope, 'my_receiver', new \Exception());
        $event->setForRetry();

        $listener->onMessageFailed($event);
    }

    public function testDoNotRedeliverToFailedWithServiceLocator()
    {
        $receiverName = 'my_receiver';

        $sender = $this->createMock(SenderInterface::class);
        $sender->expects($this->never())->method('send');
        $serviceLocator = $this->createMock(ServiceLocator::class);

        
Home | Imprint | This part of the site doesn't use cookies.