Một trang để chọn, không để học framework. Đọc nền: queue vs stream, write / read / shared, resend.
Mọi ô dưới đây giả định idempotent handler — at-least-once + redelivery là mặc định.
0. Hỏi 3 câu trước khi code retry
- Channel type? Queue destructive hay stream offset? ( A)
- Purpose? Write / read / shared? ( B)
- Lỗi? Transient (timeout, 503) hay permanent (validation, poison schema)?
1. Strategy là gì (một dòng)
- Instant retry — thử lại ngay trong process; không nhét lại channel. ( retry)
- Release — requeue / không tiến offset; giữ chỗ; dễ block nếu mãi fail.
- Ignore — ack/commit bỏ qua; message “mất” với group này.
- Resend — ack bản hiện tại + publish lại (cùng id); unblock; có thể xáo order / dual trên shared. ( C)
- Delayed resend — resend sau backoff; vàng transient write; stream thường cần retry channel phụ.
- Error channel — chuyển lane riêng (private); recovery tiếp ở đó.
- DLQ / dead letter — cất + alert + replay tay. ( poison/DLQ)
2. Matrix purpose × strategy
Ký hiệu: OK · ~ cẩn / tùy · NO tránh mặc định.
Write Read Shared
Instant retry OK OK OK
Release ~ block OK order ~ block group
Ignore ~ rare NO* ~ rare
Resend OK ~ order NO**
Delayed resend OK ~ order NO**
Error channel OK OK OK (private)
DLQ OK ~*** OK
* Read: ignore = view thiếu/sai trừ metric chấp nhận mất.
** Shared: resend shared log → double group khác.
*** Read DLQ: unblock được nhưng gap view — cần replay/backfill có quy trình.
3. Gợi ý pipeline (thực dụng)
Mọi channel:
1) Instant retry (2–3, only transient)
2) Phân loại permanent → DLQ / ignore (hiếm)
3) Final theo purpose…
Write + single group:
delayed resend / retry queue → DLQ
Read / projection:
instant retry → release/rewind (giữ order) → park + alert
(không ignore; hạn chế resend xáo per-key)
Shared stream:
instant retry → error channel RIÊNG group → DLQ
(không resend shared topic)
4. Queue vs stream — lệch triển khai
- Release trên queue: nack/requeue. Trên stream: không commit / seek lại offset group.
- Delay: queue/SQS/Rabbit delayed plugin dễ hơn; Kafka thuần hay cần topic/DB retry.
- Lease: queue claim timeout — visibility; stream ít “visibility” hơn, nghiêng processing + commit.
5. Ghép series reliability đã có
- Idempotency — lưới cuối mọi strategy.
- Backoff + jitter — delayed path; tránh storm.
- Circuit breaker — dependency chết: fail-fast, đừng release poison storm.
- Backpressure — consumer chậm ≠ chỉ tăng retry.
- Outbox — publish at-least-once có kiểm soát từ write model.
- Timeout budget — handler đừng retry vượt deadline.
6. Anti-pattern ngắn
- Một policy “always requeue” cho mọi lỗi + mọi channel.
- Ignore trên projection “cho xong lag”.
- Resend shared topic khi một group fail.
- Release mãi poison không DLQ — đốt tiền, chặn lane.
- Retry không idempotent — double charge / double email.
Một câu để nhớ
Type (queue/stream) × purpose (write/read/shared) × transient|permanent → strategy.
Không có recovery “đẹp nhất” — chỉ có recovery khớp constraint. In matrix ra wiki team cũng được; trang này là bản note.
Mục series channel & recovery
- Queue vs stream
- Write vs read vs shared
- Resend & shared
- Playbook (trang này)