Handler callback cannot say "consumed" and "stop" separately
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- php
- Domaine
- backend, distributed-systems
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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:
queue-redisskips thedelete()(Adapter.php:36)queue-amqpsendsbasic_nack($tag, false, true)(ExistingMessagesConsumer.php:45)
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 abool, - 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
LoopInterfaceit already holds.
Raised out of #340, which fixes a related case — a message refused before being handled — without touching this one.
- Langage dominant
- PHP
- Étoiles
- 61
- Forks
- 31
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de yiisoft/queue
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
-
Difficulté 4/5 1-2 jours Accessibilité débutants 47/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 54/100
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
Toutes les issues de yiisoft/queue
Issues similaires
-
sync-en
Difficulté 1/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 4 jours
-
feature request
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Automattic/blocks-engine#2803 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
hestiacp/hestiacp#5798 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Bug Component: HTTP Component: Telemetry
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100