Skip to content

Commit 22edff0

Browse files
rujchesunghyun1999
andcommitted
Fix DLQ reason/description handling in Service Bus binder
- remove redundant no-arg deadLetter() call so DeadLetterOptions is applied - strengthen regression test to guard against extra settlement interactions - update spring changelog for issue #41883 Co-authored-by: sunghyun1999 <32184099@dankook.ac.kr>
1 parent bc02f86 commit 22edff0

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

sdk/spring/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ This section includes changes in `spring-cloud-azure-docker-compose` module.
9393

9494
- Upgrade to Jackson 3 to align with Spring Boot 4 ([#49538](https://github.com/Azure/azure-sdk-for-java/issues/49538)).
9595

96+
### Spring Cloud Azure Stream Binder Service Bus
97+
98+
This section includes changes in `spring-cloud-azure-stream-binder-servicebus` module.
99+
100+
#### Bugs Fixed
101+
102+
- Fixed a regression where dead-letter reason and error description were not transmitted because a no-arg `deadLetter()` call settled the message before `deadLetter(options)` was invoked ([#41883](https://github.com/Azure/azure-sdk-for-java/issues/41883)).
103+
96104
## 6.4.0 (2026-06-01)
97105
- This release is compatible with Spring Boot 3.5.0-3.5.14. (Note: 3.5.x (x>14) should be supported, but they aren't tested with this release.)
98106
- This release is compatible with Spring Cloud 2025.0.0-2025.0.2. (Note: 2025.0.x (x>2) should be supported, but they aren't tested with this release.)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ public <T> void deadLetter(String destination,
227227
.getHeaders()
228228
.get(ServiceBusMessageHeaders.RECEIVED_MESSAGE_CONTEXT);
229229
if (messageContext != null) {
230-
messageContext.deadLetter();
231230
DeadLetterOptions options = new DeadLetterOptions();
232231
options.setDeadLetterReason(deadLetterReason);
233232
options.setDeadLetterErrorDescription(deadLetterErrorDescription);

sdk/spring/spring-cloud-azure-stream-binder-servicebus/src/test/java/com/azure/spring/cloud/stream/binder/servicebus/implementation/ServiceBusMessageChannelBinderTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
import static org.assertj.core.api.Assertions.assertThat;
3535
import static org.junit.jupiter.api.Assertions.assertEquals;
3636
import static org.mockito.Mockito.mock;
37+
import static org.mockito.Mockito.never;
3738
import static org.mockito.Mockito.verify;
39+
import static org.mockito.Mockito.verifyNoMoreInteractions;
3840
import static org.mockito.Mockito.when;
3941

4042
class ServiceBusMessageChannelBinderTest {
@@ -104,9 +106,11 @@ void testDeadLetterCalledForError() {
104106
String description = "testDescription";
105107
ErrorMessage msg = new ErrorMessage(new RuntimeException(description), originalMessage);
106108
handler.handleMessage(msg);
109+
verify(messageContext, never()).deadLetter();
107110
verify(messageContext).deadLetter(captor.capture());
108111
assertEquals("exception-message", captor.getValue().getDeadLetterReason());
109112
assertEquals(description, captor.getValue().getDeadLetterErrorDescription());
113+
verifyNoMoreInteractions(messageContext);
110114
}
111115

112116
@Test

0 commit comments

Comments
 (0)