Repository navigation
Requeue a delivery the handler refused and stop consuming - #143
Merged
Merged
Conversation
yiisoft/queue#321 removed Provider\QueueProviderInterface and Queue. The queue settings used QueueProviderInterface::DEFAULT_QUEUE as the default queue name, so the package could not be loaded with the current yiisoft/queue. It now uses DefaultQueue::NAME, which has the same value. The tests and the test console application now use AsyncQueueProducer and QueueConsumer instead of Queue, and build the worker with the current Worker constructor.
subscribe() acknowledged every delivery regardless of the handler result. The queue consumer returns false for a message it did not process (the loop was stopped), so such a message was acknowledged and lost. Now false nacks the delivery with requeue, cancels the consumer and stops the wait loop; deliveries that arrive after that are requeued without calling the handler.
samdark
force-pushed
the
fix-346-requeue-refused-delivery
branch
from
October 28, 2026 21:58
25578f3 to
c9a8311
Compare
KalimeroMK
approved these changes
Oct 28, 2026
KalimeroMK
left a comment
There was a problem hiding this comment.
Matches what runExisting() already does, and the three paths are covered. Two notes inline, neither blocking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to yiisoft/queue#346. It should be merged together with yiisoft/queue#349.
It builds on #144, which makes the package work with the current yiisoft/queue, and includes its commit. Merge #144 first.
Adapter::subscribe()acknowledged every delivery after calling the handler, whatever the handler returned. With yiisoft/queue#349,QueueConsumerreturnsfalsefor a message it did not process because the loop has stopped. Such a delivery, for example one that arrives duringwait()afterSIGTERMor a prefetched one, would be acknowledged without being processed, and so lost.Now
subscribe()handles the handler result:true: the delivery is acknowledged, as before.false: the delivery is nacked with requeue, the consumer is cancelled and the wait loop stops.runExisting()already requeued a refused message and is unchanged.The two changes have to land together. Without this one, yiisoft/queue#349 lets unprocessed AMQP deliveries be acknowledged. Without yiisoft/queue#349, the current
QueueConsumerreturnsfalseafter processing a message when the loop stops, so that message would be requeued and processed twice.