Handler callback cannot say "consumed" and "stop" separately
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
- Lĩnh vực
- backend, distributed-systems
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:
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.
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của yiisoft/queue
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 47/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 54/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Tất cả issue của yiisoft/queue
Issue tương tự
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Перевод устарел
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 62/100
-
feature request
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
home php
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
vincent-peugnet/wcms#670 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
freescout-help-desk/freescout#5731 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày