Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#346 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
61
Fork
31
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của yiisoft/queue

Tất cả issue của yiisoft/queue

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.