feat(consumer): one-call dead-letter queue setup#18
Conversation
Add ConsumerConfig.WithDeadLetterQueue (with DeadLetterConfig and DefaultDeadLetterConfig): it declares the dead-letter exchange, the dead-letter queue, the binding between them, and wires the work queue's x-dead-letter-exchange — replacing four hand-written declarations. Like the rest of the consumer topology, it is re-applied in applyTopology on every channel setup, so it survives reconnects and broker restarts. Add Consumer.DeadLetterQueueName() so a second consumer can read the DLQ without re-deriving the name. Pairs with the v0.6.0 reject-by-default behaviour: a failed handler now dead-letters into the configured DLQ instead of discarding.
|
Warning Review limit reached
Next review available in: 39 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR adds one-call dead-letter queue (DLQ) support to the consumer API: a new ChangesDead-Letter Queue Feature
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Publisher
participant WorkQueue
participant Consumer
participant DLX
participant DLQConsumer
Publisher->>WorkQueue: publish message
WorkQueue->>Consumer: deliver message
Consumer->>Consumer: handler fails, reject
Consumer->>DLX: message dead-lettered
DLX->>DLQConsumer: deliver to DLQ
Note over Consumer: connection dropped/reconnected
Consumer->>Consumer: applyTopology re-declares DLX/DLQ/bind
Publisher->>WorkQueue: publish message again
WorkQueue->>Consumer: deliver, handler fails
Consumer->>DLX: message dead-lettered
DLX->>DLQConsumer: deliver to DLQ
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@consumer.go`:
- Around line 183-210: The issue is that WithDeadLetterQueue forces a
QueueConfig even when ConsumerConfig.Queue is empty, which breaks the
server-named queue path and can orphan queues on reconnect. Update
WithDeadLetterQueue to guard against anonymous work queues by failing fast when
c.Queue is empty and c.QueueConfig is nil, or preserve the existing server-named
behavior instead of synthesizing a QueueConfig; keep the fix centered in
ConsumerConfig.WithDeadLetterQueue and the topology setup flow it feeds.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3b7706b8-fa40-471f-a83a-f3cab215f307
📒 Files selected for processing (5)
CHANGELOG.mdREADME.mdconsumer.goconsumer_test.gointegration_test.go
Add ConsumerConfig.WithDeadLetterQueue (with DeadLetterConfig and DefaultDeadLetterConfig): it declares the dead-letter exchange, the dead-letter queue, the binding between them, and wires the work queue's x-dead-letter-exchange — replacing four hand-written declarations. Like the rest of the consumer topology, it is re-applied in applyTopology on every channel setup, so it survives reconnects and broker restarts.
Add Consumer.DeadLetterQueueName() so a second consumer can read the DLQ without re-deriving the name.
Pairs with the v0.6.0 reject-by-default behaviour: a failed handler now dead-letters into the configured DLQ instead of discarding.
Summary
Motivation
Fixes #
Changes
Checklist
make all)Summary by CodeRabbit
New Features
Bug Fixes
Documentation