Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Handler callback cannot say "consumed" and "stop" separately

Offen
#346 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
php

Rechercherichtung

Start with the runExisting() and subscribe() callback contracts and trace how adapters use their boolean result; the issue names queue-redis Adapter.php:36 and queue-amqp ExistingMessagesConsumer.php:45 as examples. Compare the graceful shutdown path with run($max) counting, then evaluate how a revised result can preserve both consumption and stop status across the shared contract. Done when handled messages are acknowledged and counted even as the loop stops, while refused messages remain unconsumed.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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():

private function handle(MessageInterface $message): bool
{
    $this->worker->process($message, $this->queueName);
    return $this->loop->canContinue();
}

So when SignalLoop sees SIGTERM, the callback returns false for a message that was handled to completion. Every adapter then keeps it:

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.

Vorherrschende Sprache
PHP
Sterne
61
Forks
31
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus yiisoft/queue

Alle Issues in yiisoft/queue

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.