-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,14 +133,19 @@ public function reject(Message $message, bool $requeue = false): void | |
{ | ||
InvalidMessageException::assertMessageInstanceOf($message, SqsMessage::class); | ||
|
||
$this->context->getSqsClient()->deleteMessage([ | ||
'@region' => $this->queue->getRegion(), | ||
'QueueUrl' => $this->context->getQueueUrl($this->queue), | ||
'ReceiptHandle' => $message->getReceiptHandle(), | ||
]); | ||
|
||
if ($requeue) { | ||
$this->context->createProducer()->send($this->queue, $message); | ||
$this->context->getAwsSqsClient()->changeMessageVisibility([ | ||
'@region' => $this->queue->getRegion(), | ||
'QueueUrl' => $this->context->getQueueUrl($this->queue), | ||
'ReceiptHandle' => $message->getReceiptHandle(), | ||
'VisibilityTimeout' => 0, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
makasim
Member
|
||
]); | ||
} else { | ||
$this->context->getSqsClient()->deleteMessage([ | ||
'@region' => $this->queue->getRegion(), | ||
'QueueUrl' => $this->context->getQueueUrl($this->queue), | ||
'ReceiptHandle' => $message->getReceiptHandle(), | ||
]); | ||
} | ||
} | ||
|
||
|
Thanks @cshum for this better behaviour when requeuing a message in a processor.
I'm proposing here to make a slighty change to this behaviour by setting the VisibilityTimeout based on the
getDelaySeconds
of the SQS message.I see a real interest in this, as this would allow us to requeue a message and add a delay before it can be consumed again by setting a delay on the message in the processor just before returning
Processor::REQUEUE
.Concretly the code would be here:
'VisibilityTimeout' => $message->getDelaySeconds(),
Before doing a PR, I prefer to ask if you too would see an interest on this update. What do you think?
ping @makasim @cshum