From 569a848c8b40014a835cf3dbc21d579e53bf0688 Mon Sep 17 00:00:00 2001 From: Absorbing Date: Fri, 9 Feb 2024 18:08:50 +0000 Subject: [PATCH] Add delay capability to rejections for Dbal --- pkg/dbal/DbalConsumer.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/dbal/DbalConsumer.php b/pkg/dbal/DbalConsumer.php index f1f397441..80a3b4c92 100644 --- a/pkg/dbal/DbalConsumer.php +++ b/pkg/dbal/DbalConsumer.php @@ -38,6 +38,11 @@ class DbalConsumer implements Consumer */ private $redeliveryDelay; + /** + * @var int + */ + private $deliveryDelay; + public function __construct(DbalContext $context, DbalDestination $queue) { $this->context = $context; @@ -65,6 +70,19 @@ public function setRedeliveryDelay(int $redeliveryDelay): self return $this; } + /** + * @return int + */ + public function getDeliveryDelay(): ?int + { + return $this->deliveryDelay; + } + + public function setDeliveryDelay(int $deliveryDelay): void + { + $this->deliveryDelay = $deliveryDelay; + } + /** * @return DbalDestination */ @@ -104,6 +122,10 @@ public function reject(Message $message, bool $requeue = false): void $message = clone $message; $message->setRedelivered(false); + if(null !== $this->deliveryDelay && null === $message->getDeliveryDelay()) { + $message->setDeliveryDelay($this->deliveryDelay); + } + $this->getContext()->createProducer()->send($this->queue, $message); }