Repository navigation
Keep the message that hits the limit in the queue - #340
Open
KalimeroMK wants to merge 1 commit into
Open
KalimeroMK wants to merge 1 commit into
KalimeroMK wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #340 +/- ##
=========================================
Coverage 94.58% 94.58%
Complexity 373 373
=========================================
Files 59 59
Lines 978 978
=========================================
Hits 925 925
Misses 53 53 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
Pushed a follow-up: the fix left |
`queue:run --limit=1` over two queued messages reported one processed and left the queue empty: `InMemoryAdapter::runExisting()` removed the message that tripped the limit even though the callback returned `false` without handling it. Both shipped adapters already treat `false` as "not consumed" — `queue-redis` deletes only when the callback returned `true`, `queue-amqp` nacks with requeue otherwise — so the stub was the outlier. Spell that contract out on `runExisting()` and `subscribe()`.
KalimeroMK
force-pushed
the
fix-limit-message-loss
branch
from
October 12, 2026 22:14
9a65e0f to
a258088
Compare
QueueConsumer::run() hits the limit
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.
What does this PR do?
queue:run --limit=1over two queued messages printsMessages processed: 1.and leaves the queue empty. The second message is discarded without ever reaching a handler.Cause
QueueConsumer::run()returnsfalsefrom the callback for the message that trips the limit, without handling it.InMemoryAdapter::runExisting()unsets the message anyway, before it looks at what the callback returned:Both shipped adapters already read
falseas "not consumed":queue-redis—if ($result) { $this->provider->delete(...); }(Adapter.php:35)queue-amqp—if ($this->messageConsumed = $callback($message)) { basic_ack(); } else { basic_nack($tag, false, true); }(ExistingMessagesConsumer.php:42)So the stub is the outlier, and
AdapterInterfacenever said which reading was intended — it only said "Returns false if it cannot continue handling messages".Fix
InMemoryAdapterkeeps a message the callback refused, andrunExisting()/subscribe()state the contract the other adapters already implement.QueueConsumeris unchanged.Not addressed here
One bit cannot carry both "was this message consumed?" and "should I continue?". When the loop stops after a message was handled (
SignalLooponSIGTERM), the callback returnsfalsefor a message that was processed, so it is kept and processed again on the next run. Every adapter behaves this way today; splitting the two signals is anAdapterInterfacechange and belongs in its own issue: #346.Validation
Both new assertions fail without the fix (
actual size 0 matches expected size 1,actual size 1 matches expected size 2) and pass with it. Full suite: 280 tests, 516 assertions, OK. Psalm and PHP CS Fixer clean.