Skip to content

Commit be43295

Browse files
committed
Update doc for JmsResponse
Issue: SPR-13133
1 parent 600e591 commit be43295

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/asciidoc/integration.adoc

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,8 +2739,8 @@ annotate the payload with `@Valid` and configure the necessary validator as foll
27392739
}
27402740
----
27412741

2742-
[[jms-annotated-reply]]
2743-
==== Reply management
2742+
[[jms-annotated-response]]
2743+
==== Response management
27442744

27452745
The existing support in <<jms-receiving-async-message-listener-adapter,MessageListenerAdapter>>
27462746
already allows your method to have a non-`void` return type. When that's the case, the result of
@@ -2750,7 +2750,7 @@ the listener. That default destination can now be set using the `@SendTo` annota
27502750
messaging abstraction.
27512751

27522752
Assuming our `processOrder` method should now return an `OrderStatus`, it is possible to write it
2753-
as follow to automatically send a reply:
2753+
as follow to automatically send a response:
27542754

27552755
[source,java,indent=0]
27562756
[subs="verbatim,quotes"]
@@ -2780,6 +2780,26 @@ If you need to set additional headers in a transport-independent manner, you cou
27802780
}
27812781
----
27822782

2783+
If you need to compute the response destination at runtime, you can encapsulate your response
2784+
in a `JmsResponse` instance that also provides the destination to use at runtime. The previous
2785+
example can be rewritten as follows:
2786+
2787+
[source,java,indent=0]
2788+
[subs="verbatim,quotes"]
2789+
----
2790+
@JmsListener(destination = "myDestination")
2791+
public JmsResponse<Message<OrderStatus>> processOrder(Order order) {
2792+
// order processing
2793+
Message<OrderStatus> response = MessageBuilder
2794+
.withPayload(status)
2795+
.setHeader("code", 1234)
2796+
.build();
2797+
return JmsResponse.forQueue(response, "status");
2798+
}
2799+
----
2800+
2801+
2802+
27832803
[[jms-namespace]]
27842804
=== JMS Namespace Support
27852805
Spring provides an XML namespace for simplifying JMS configuration. To use the JMS

src/asciidoc/whats-new.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ public @interface MyTestConfig {
486486
* The `autoStartup` attribute can be controlled via `JmsListenerContainerFactory`.
487487
* The type of the reply `Destination` can now be configured per listener container.
488488
* The value of the `@SendTo` annotation can now use a SpEL expression.
489+
* The response destination can be <<jms-annotated-response,computed at runtime using `JmsResponse`>>
489490

490491
=== Web Improvements
491492

0 commit comments

Comments
 (0)