Skip to content

Fix DLQ reason and description not transmitted in ServiceBus binder#49662

Closed
sunghyun1999 wants to merge 2 commits into
Azure:mainfrom
sunghyun1999:fix/servicebus-dlq-reason-41883
Closed

Fix DLQ reason and description not transmitted in ServiceBus binder#49662
sunghyun1999 wants to merge 2 commits into
Azure:mainfrom
sunghyun1999:fix/servicebus-dlq-reason-41883

Conversation

@sunghyun1999

Copy link
Copy Markdown

Summary

Root Cause

// Before (bug): line 230 settles the message immediately without reason/description
messageContext.deadLetter();          // ← settles message, no reason
messageContext.deadLetter(options);   // ← ignored, message already settled

// After (fix): only the parameterized call remains
messageContext.deadLetter(options);   // ← settles with reason and description

Test Plan

  • Verified the code change by reviewing the deadLetter method logic
  • The fix aligns with the approach suggested by the issue reporter and confirmed by @dreyinger

Fixes #41883

🤖 Generated with Claude Code

…nder

Remove the redundant no-arg `deadLetter()` call that settles the message
before the parameterized `deadLetter(options)` call can set the reason
and error description.

Fixes Azure#41883

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 29, 2026 01:39
@github-actions github-actions Bot added azure-spring All azure-spring related issues Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Jun 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution @sunghyun1999! We will review the pull request and get back to you soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the Spring Cloud Azure Service Bus Stream Binder where the dead-letter reason and error description were not being transmitted, due to a redundant no-arg deadLetter() call settling the message before the parameterized deadLetter(options) call could apply the details.

Changes:

  • Removed the redundant no-arg messageContext.deadLetter() call so the message is dead-lettered only via DeadLetterOptions.
  • Ensured DLQ reason and description can be applied when dead-lettering received messages.
Comments suppressed due to low confidence (1)

sdk/spring/spring-cloud-azure-stream-binder-servicebus/src/main/java/com/azure/spring/cloud/stream/binder/servicebus/implementation/ServiceBusMessageChannelBinder.java:233

  • The current test coverage doesn’t guard against regressions where messageContext.deadLetter() (no-arg) is called before messageContext.deadLetter(options). That exact sequencing caused the original bug (options ignored after settlement), but ServiceBusMessageChannelBinderTest.testDeadLetterCalledForError only verifies the parameterized overload was called (and would still pass if an extra no-arg deadLetter call happened). Consider strengthening the test to assert the no-arg overload is never invoked (e.g., verify(messageContext, never()).deadLetter(); and/or verifyNoMoreInteractions(messageContext) after the options verification).
        final ServiceBusReceivedMessageContext messageContext = (ServiceBusReceivedMessageContext) message
            .getHeaders()
            .get(ServiceBusMessageHeaders.RECEIVED_MESSAGE_CONTEXT);
        if (messageContext != null) {
            DeadLetterOptions options = new DeadLetterOptions();
            options.setDeadLetterReason(deadLetterReason);
            options.setDeadLetterErrorDescription(deadLetterErrorDescription);
            messageContext.deadLetter(options);

Strengthen the existing testDeadLetterCalledForError test to assert that
the no-arg deadLetter() (which settles the message without reason) is
never invoked, preventing the original bug from being reintroduced.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rujche rujche self-assigned this Jun 29, 2026
@rujche rujche added this to the 2026-07 milestone Jun 29, 2026
@rujche

rujche commented Jun 29, 2026

Copy link
Copy Markdown
Member

Closing in favor of #49663

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure-spring All azure-spring related issues Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

Status: Cut

Development

Successfully merging this pull request may close these issues.

[BUG] DLQ reason and description not working in spring-cloud-azure-stream-binder-servicebus

4 participants