Skip to content

Commit

Permalink
Added support for DelayStamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Kocjan authored and Nyholm committed Jan 19, 2020
1 parent 90fae73 commit 0e4c934
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions QueueInteropTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Interop\Queue\Message;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\LogicException;
use Symfony\Component\Messenger\Stamp\DelayStamp;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
use Symfony\Component\Messenger\Transport\TransportInterface;
use Symfony\Component\OptionsResolver\Options;
Expand Down Expand Up @@ -129,12 +130,20 @@ public function send(Envelope $envelope): Envelope

$producer = $context->createProducer();

if (isset($this->options['deliveryDelay'])) {
$delay = 0;
$delayStamp = $envelope->last(DelayStamp::class);
if (null !== $delayStamp) {
$delay = $delayStamp->getDelay();
} elseif (isset($this->options['deliveryDelay'])) {
$delay = $this->options['deliveryDelay'];
}
if ($delay > 0) {
if ($producer instanceof DelayStrategyAware) {
$producer->setDelayStrategy($this->options['delayStrategy']);
}
$producer->setDeliveryDelay($this->options['deliveryDelay']);
$producer->setDeliveryDelay($delay);
}

if (isset($this->options['priority'])) {
$producer->setPriority($this->options['priority']);
}
Expand Down

0 comments on commit 0e4c934

Please sign in to comment.