Class JmsResponse<T>
java.lang.Object
org.springframework.jms.listener.adapter.JmsResponse<T>
- Type Parameters:
T
- the type of the response
Return type of any JMS listener method used to indicate the actual response
destination alongside the response itself. Typically used when said destination
needs to be computed at runtime.
The example below sends a response with the content of the result
argument to the queueOut Queue
:
package com.acme.foo; public class MyService { @JmsListener public JmsResponse process(String msg) { // process incoming message return JmsResponse.forQueue(result, "queueOut"); } }If the destination does not need to be computed at runtime,
@SendTo
is the recommended declarative approach.- Since:
- 4.2
- Author:
- Stephane Nicoll
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
JmsResponse
(T response, Object destination) Create a newJmsResponse
instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> JmsResponse<T>
forDestination
(T result, Destination destination) Create aJmsResponse
targeting the specifiedDestination
.static <T> JmsResponse<T>
Create aJmsResponse
targeting the queue with the specified name.static <T> JmsResponse<T>
Create aJmsResponse
targeting the topic with the specified name.Return the content of the response.resolveDestination
(DestinationResolver destinationResolver, Session session) Resolve theDestination
to use for this instance.toString()
-
Constructor Details
-
JmsResponse
Create a newJmsResponse
instance.- Parameters:
response
- the content of the responsedestination
- the destination
-
-
Method Details
-
getResponse
Return the content of the response. -
resolveDestination
@Nullable public Destination resolveDestination(DestinationResolver destinationResolver, Session session) throws JMSException Resolve theDestination
to use for this instance. TheDestinationResolver
andSession
can be used to resolve a destination at runtime.- Parameters:
destinationResolver
- the destination resolver to use if necessarysession
- the session to use, if necessary- Returns:
- the
Destination
to use - Throws:
JMSException
- if the DestinationResolver failed to resolve the destination
-
toString
-
forQueue
Create aJmsResponse
targeting the queue with the specified name. -
forTopic
Create aJmsResponse
targeting the topic with the specified name. -
forDestination
Create aJmsResponse
targeting the specifiedDestination
.
-