Handler callback cannot say "consumed" and "stop" separately
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- php
- Domínio
- backend, distributed-systems
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- PHP
- Estrelas
- 61
- Forks
- 31
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de yiisoft/queue
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
-
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 47/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 54/100
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
Todas as issues de yiisoft/queue
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
Automattic/blocks-engine#2866 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
community-scripts/ProxmoxVE#17944 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
EasyCorp/EasyAdminBundle#7861 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
Good first issue: add laravel-inertia stack budget preset (Laravel 11 + Inertia.js + PHP 8.3)Abertaenhancement good first issue help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
-
backend gamification P0
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
semanadeinformatica/website#461 ·