You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handler callback cannot say "consumed" and "stop" separately #346
The handler callback passed to runExisting() and subscribe() returns one bool, and it is asked to carry two independent facts: whether the message was consumed, and whether the adapter should keep delivering.
They disagree on graceful shutdown. QueueConsumer::handle() processes the message and then returns $this->loop->canContinue():
The message is processed again on the next run. For a non-idempotent handler — a charge, an email, a webhook — that is a duplicate on every restart, deploy or scale-down, which is when SIGTERM arrives.
run($max) has the same shape: it reports $count messages processed, but the message handled just before the loop stops is not counted, because the early return skips the increment.
Both fall out of the single return value, so they cannot be fixed in a consumer or in an adapter alone. Some options:
the callback returns an enum (Consumed, ConsumedAndStop, NotConsumed) instead of a bool,
or the adapter asks separately, e.g. the callback stays "was it consumed" and the loop is checked by the adapter through a second callback or a LoopInterface it already holds.
Raised out of #340, which fixes a related case — a message refused before being handled — without touching this one.
Activity