Skip to content

Commit

Permalink
Add RedeliveryStamp support (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartakusMd authored Oct 13, 2024
1 parent 08a7f4d commit 80668ce
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Transport/QueueReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\Messenger\Exception\LogicException;
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;
use Symfony\Component\Messenger\Exception\TransportException;
use Symfony\Component\Messenger\Stamp\RedeliveryStamp;
use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp;
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
Expand Down Expand Up @@ -130,10 +131,16 @@ private function createEnvelopeFromMessage(Message $message): Envelope
throw $exception;
}

return $envelope->with(
$stamps = [
new TransportMessageIdStamp($message->getOriginal()->getMessageId()),
new QueueReceivedStamp($message->getOriginal()->getPopReceipt())
);
];

if ($message->getOriginal()->getDequeueCount() > 1) {
$stamps[] = new RedeliveryStamp($message->getOriginal()->getDequeueCount());
}

return $envelope->with(...$stamps);
}

/**
Expand Down

0 comments on commit 80668ce

Please sign in to comment.