@@ -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
27452745The existing support in <<jms-receiving-async-message-listener-adapter,MessageListenerAdapter>>
27462746already 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
27502750messaging abstraction.
27512751
27522752Assuming 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
27852805Spring provides an XML namespace for simplifying JMS configuration. To use the JMS
0 commit comments