类 JmsResponse<T>
- java.lang.Object
- org.springframework.jms.listener.adapter.JmsResponse<T>
- 类型参数:
T
- the type of the response
public class JmsResponse<T> extends Object
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 thequeueOut 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.- 从以下版本开始:
- 4.2
- 作者:
- Stephane Nicoll
- 另请参阅:
JmsListener
,SendTo
构造器概要
构造器 限定符 构造器 说明 protected
JmsResponse(T response, Object destination)
Create a new instance
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 static <T> JmsResponse<T>
forDestination(T result, Destination destination)
Create aJmsResponse
targeting the specifiedDestination
.static <T> JmsResponse<T>
forQueue(T result, String queueName)
Create aJmsResponse
targeting the queue with the specified name.static <T> JmsResponse<T>
forTopic(T result, String topicName)
Create aJmsResponse
targeting the topic with the specified name.T
getResponse()
Return the content of the response.Destination
resolveDestination(DestinationResolver destinationResolver, Session session)
Resolve theDestination
to use for this instance.String
toString()
构造器详细资料
JmsResponse
protected JmsResponse(T response, Object destination)
Create a new instance- 参数:
response
- the content of the resultdestination
- the destination
方法详细资料
getResponse
public T getResponse()
Return the content of the response.
resolveDestination
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.- 参数:
destinationResolver
- the destination resolver to use if necessarysession
- the session to use, if necessary- 返回:
- the
Destination
to use - 抛出:
JMSException
- if the DestinationResolver failed to resolve the destination
forQueue
public static <T> JmsResponse<T> forQueue(T result, String queueName)
Create aJmsResponse
targeting the queue with the specified name.
forTopic
public static <T> JmsResponse<T> forTopic(T result, String topicName)
Create aJmsResponse
targeting the topic with the specified name.
forDestination
public static <T> JmsResponse<T> forDestination(T result, Destination destination)
Create aJmsResponse
targeting the specifiedDestination
.