Skip to content

Commit 68dcc77

Browse files
authored
fix: redis redelivery_delay setting does not work
When using the redis transport, RedisConsumer::processResult() creates the redelivered record prior to the RedisSubscription callback executing. The subscription callback attached with Enqueue\Consumption\QueueConsumer then invokes RedisConsumer::reject(). Calling acknowledge() deletes the redelivered record which was created earlier. Thus, we should not create a new record in reject() and we should only call acknowledge() if we do not wish to redeliver. I have tested and confirmed that this change fixes the issue. However, if there is a better solution, please advise. Resolves php-enqueue#1342
1 parent bb6e759 commit 68dcc77

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

pkg/redis/RedisConsumer.php

+2-13
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,8 @@ public function reject(Message $message, bool $requeue = false): void
9696
{
9797
InvalidMessageException::assertMessageInstanceOf($message, RedisMessage::class);
9898

99-
$this->acknowledge($message);
100-
101-
if ($requeue) {
102-
$message = $this->getContext()->getSerializer()->toMessage($message->getReservedKey());
103-
$message->setRedelivered(true);
104-
105-
if ($message->getTimeToLive()) {
106-
$message->setHeader('expires_at', time() + $message->getTimeToLive());
107-
}
108-
109-
$payload = $this->getContext()->getSerializer()->toString($message);
110-
111-
$this->getRedis()->lpush($this->queue->getName(), $payload);
99+
if (!$requeue) {
100+
$this->acknowledge($message);
112101
}
113102
}
114103

0 commit comments

Comments
 (0)