Class JmsResponse<T>

  • java.lang.Object
    • org.springframework.jms.listener.adapter.JmsResponse<T>
  • Type Parameters:
    T - the type of the response

    public class JmsResponse<T>
    extends java.lang.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 the queueOut Queue:

     public class MyService {
         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.
    Stephane Nicoll
    See Also:
    JmsListener, SendTo
    • Constructor Detail

      • JmsResponse

        protected JmsResponse(T response,
                              java.lang.Object destination)
        Create a new JmsResponse instance.
        response - the content of the result
        destination - the destination
    • Method Detail

      • getResponse

        public T getResponse()
        Return the content of the response.
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object
      • forQueue

        public static <T> JmsResponse<T> forQueue(T result,
                                                  java.lang.String queueName)
        Create a JmsResponse targeting the queue with the specified name.
      • forTopic

        public static <T> JmsResponse<T> forTopic(T result,
                                                  java.lang.String topicName)
        Create a JmsResponse targeting the topic with the specified name.