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
ConstructorsModifierConstructorDescriptionprotectedJmsResponse(T response, Object destination) Create a newJmsResponseinstance. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> JmsResponse<T>forDestination(T result, Destination destination) Create aJmsResponsetargeting the specifiedDestination.static <T> JmsResponse<T>Create aJmsResponsetargeting the queue with the specified name.static <T> JmsResponse<T>Create aJmsResponsetargeting the topic with the specified name.Return the content of the response.resolveDestination(DestinationResolver destinationResolver, Session session) Resolve theDestinationto use for this instance.toString()
-
Constructor Details
-
JmsResponse
Create a newJmsResponseinstance.- Parameters:
response- the content of the resultdestination- the destination
-
-
Method Details
-
getResponse
Return the content of the response. -
resolveDestination
@Nullable public Destination resolveDestination(DestinationResolver destinationResolver, Session session) throws JMSException Resolve theDestinationto use for this instance. TheDestinationResolverandSessioncan 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
Destinationto use - Throws:
JMSException- if the DestinationResolver failed to resolve the destination
-
toString
-
forQueue
Create aJmsResponsetargeting the queue with the specified name. -
forTopic
Create aJmsResponsetargeting the topic with the specified name. -
forDestination
Create aJmsResponsetargeting the specifiedDestination.
-