Class JmsMessagingTemplate

java.lang.Object
org.springframework.messaging.core.AbstractMessageSendingTemplate<jakarta.jms.Destination>
org.springframework.messaging.core.AbstractMessageReceivingTemplate<jakarta.jms.Destination>
org.springframework.messaging.core.AbstractMessagingTemplate<jakarta.jms.Destination>
org.springframework.jms.core.JmsMessagingTemplate
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, JmsMessageOperations, org.springframework.messaging.core.MessageReceivingOperations<jakarta.jms.Destination>, org.springframework.messaging.core.MessageRequestReplyOperations<jakarta.jms.Destination>, org.springframework.messaging.core.MessageSendingOperations<jakarta.jms.Destination>

public class JmsMessagingTemplate extends org.springframework.messaging.core.AbstractMessagingTemplate<jakarta.jms.Destination> implements JmsMessageOperations, org.springframework.beans.factory.InitializingBean
An implementation of JmsMessageOperations, as a wrapper on top of Spring's traditional JmsTemplate. Aligned with the spring-messaging module and GenericMessagingTemplate.

Note: Operations in this interface throw MessagingException instead of the JMS-specific JmsException, aligning with the spring-messaging module and its other client operation handles.

Since:
4.1
Author:
Stephane Nicoll, Juergen Hoeller
See Also:
  • Field Summary

    Fields inherited from class org.springframework.messaging.core.AbstractMessageSendingTemplate

    CONVERSION_HINT_HEADER, logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for use with bean properties.
    JmsMessagingTemplate(jakarta.jms.ConnectionFactory connectionFactory)
    Create a JmsMessagingTemplate instance with the JMS ConnectionFactory to use, implicitly building a JmsTemplate based on it.
    Create a JmsMessagingTemplate instance with the JmsOperations to use.
    Create a JmsMessagingTemplate instance with the JmsTemplate to use.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    convertAndSend(Object payload, @Nullable Map<String,Object> headers, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor)
     
    void
    convertAndSend(String destinationName, Object payload)
    Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message and send it to the given destination.
    void
    convertAndSend(String destinationName, Object payload, @Nullable Map<String,Object> headers)
    Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers and send it to the given destination.
    void
    convertAndSend(String destinationName, Object payload, @Nullable Map<String,Object> headers, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor)
    Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers, apply the given post-processor, and send the resulting message to the given destination.
    void
    convertAndSend(String destinationName, Object payload, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor)
    Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message, apply the given post-processor, and send the resulting message to the given destination.
    protected org.springframework.messaging.MessagingException
     
    protected @Nullable org.springframework.messaging.Message<?>
    convertJmsMessage(@Nullable jakarta.jms.Message message)
     
    <T> @Nullable T
    convertSendAndReceive(Object request, Class<T> targetClass)
     
    <T> @Nullable T
    convertSendAndReceive(Object request, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor)
     
    <T> @Nullable T
    convertSendAndReceive(Object request, @Nullable Map<String,Object> headers, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor)
     
    <T> @Nullable T
    convertSendAndReceive(String destinationName, Object request, Class<T> targetClass)
    Convert the given request Object to serialized form, possibly using a MessageConverter, send it as a Message to the given destination, receive the reply and convert its body of the specified target class.
    <T> @Nullable T
    convertSendAndReceive(String destinationName, Object request, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor requestPostProcessor)
    Convert the given request Object to serialized form, possibly using a MessageConverter, apply the given post-processor and send the resulting Message to the given destination, receive the reply and convert its body of the given target class.
    <T> @Nullable T
    convertSendAndReceive(String destinationName, Object request, @Nullable Map<String,Object> headers, Class<T> targetClass)
    Convert the given request Object to serialized form, possibly using a MessageConverter, send it as a Message with the given headers, to the specified destination, receive the reply and convert its body of the specified target class.
    <T> @Nullable T
    convertSendAndReceive(String destinationName, Object request, @Nullable Map<String,Object> headers, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor)
    Convert the given request Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers, apply the given post-processor and send the resulting Message to the specified destination, receive the reply and convert its body of the given target class.
    protected @Nullable org.springframework.messaging.Message<?>
    doReceive(jakarta.jms.Destination destination)
     
    protected @Nullable org.springframework.messaging.Message<?>
    doReceive(String destinationName)
     
    protected @Nullable org.springframework.messaging.Message<?>
    doReceiveSelected(jakarta.jms.Destination destination, @Nullable String messageSelector)
     
    protected @Nullable org.springframework.messaging.Message<?>
    doReceiveSelected(String destinationName, @Nullable String messageSelector)
     
    protected void
    doSend(jakarta.jms.Destination destination, org.springframework.messaging.Message<?> message)
     
    protected void
    doSend(String destinationName, org.springframework.messaging.Message<?> message)
     
    protected @Nullable org.springframework.messaging.Message<?>
    doSendAndReceive(jakarta.jms.Destination destination, org.springframework.messaging.Message<?> requestMessage)
     
    protected @Nullable org.springframework.messaging.Message<?>
    doSendAndReceive(String destinationName, org.springframework.messaging.Message<?> requestMessage)
     
    @Nullable jakarta.jms.ConnectionFactory
    Return the ConnectionFactory that the underlying JmsTemplate uses.
    Return the configured default destination name.
    Return the MessageConverter to use to convert a Message to and from a Message.
    Return the configured JmsTemplate.
    protected String
     
    @Nullable org.springframework.messaging.Message<?>
     
    @Nullable org.springframework.messaging.Message<?>
    receive(String destinationName)
    Receive a message from the given destination.
    <T> @Nullable T
    receiveAndConvert(Class<T> targetClass)
     
    <T> @Nullable T
    receiveAndConvert(String destinationName, Class<T> targetClass)
    Receive a message from the given destination and convert its payload to the specified target class.
    @Nullable org.springframework.messaging.Message<?>
    receiveSelected(jakarta.jms.Destination destination, @Nullable String messageSelector)
    Receive a message from the given destination.
    @Nullable org.springframework.messaging.Message<?>
    receiveSelected(@Nullable String messageSelector)
    Receive a message from the default destination.
    @Nullable org.springframework.messaging.Message<?>
    receiveSelected(String destinationName, @Nullable String messageSelector)
    Receive a message from the given destination.
    <T> @Nullable T
    receiveSelectedAndConvert(jakarta.jms.Destination destination, @Nullable String messageSelector, Class<T> targetClass)
    Receive a message from the given destination and convert its payload to the specified target class.
    <T> @Nullable T
    receiveSelectedAndConvert(@Nullable String messageSelector, Class<T> targetClass)
    Receive a message from the default destination and convert its payload to the specified target class.
    <T> @Nullable T
    receiveSelectedAndConvert(String destinationName, @Nullable String messageSelector, Class<T> targetClass)
    Receive a message from the given destination and convert its payload to the specified target class.
    void
    send(String destinationName, org.springframework.messaging.Message<?> message)
    Send a message to the given destination.
    void
    send(org.springframework.messaging.Message<?> message)
     
    @Nullable org.springframework.messaging.Message<?>
    sendAndReceive(String destinationName, org.springframework.messaging.Message<?> requestMessage)
    Send a request message and receive the reply from the given destination.
    @Nullable org.springframework.messaging.Message<?>
    sendAndReceive(org.springframework.messaging.Message<?> requestMessage)
     
    void
    setConnectionFactory(jakarta.jms.ConnectionFactory connectionFactory)
    Set the ConnectionFactory to use for the underlying JmsTemplate.
    void
    setDefaultDestinationName(@Nullable String defaultDestinationName)
    Configure the default destination name to use in send methods that don't have a destination argument.
    void
    Set the MessageConverter to use to convert a Message to and from a Message.
    void
    Set the JmsTemplate to use.

    Methods inherited from class org.springframework.messaging.core.AbstractMessagingTemplate

    convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive

    Methods inherited from class org.springframework.messaging.core.AbstractMessageReceivingTemplate

    doConvert, receive, receiveAndConvert

    Methods inherited from class org.springframework.messaging.core.AbstractMessageSendingTemplate

    convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, setDefaultDestination, setMessageConverter

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.messaging.core.MessageReceivingOperations

    receive, receiveAndConvert

    Methods inherited from interface org.springframework.messaging.core.MessageRequestReplyOperations

    convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive

    Methods inherited from interface org.springframework.messaging.core.MessageSendingOperations

    convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, send
  • Constructor Details

    • JmsMessagingTemplate

      public JmsMessagingTemplate()
      Constructor for use with bean properties. Requires setConnectionFactory(ConnectionFactory) or setJmsTemplate(JmsTemplate) to be called.
    • JmsMessagingTemplate

      public JmsMessagingTemplate(jakarta.jms.ConnectionFactory connectionFactory)
      Create a JmsMessagingTemplate instance with the JMS ConnectionFactory to use, implicitly building a JmsTemplate based on it.
      Since:
      4.1.2
    • JmsMessagingTemplate

      public JmsMessagingTemplate(JmsTemplate jmsTemplate)
      Create a JmsMessagingTemplate instance with the JmsTemplate to use.
    • JmsMessagingTemplate

      public JmsMessagingTemplate(JmsOperations jmsTemplate)
      Create a JmsMessagingTemplate instance with the JmsOperations to use.
      Since:
      7.0
  • Method Details

    • setConnectionFactory

      public void setConnectionFactory(jakarta.jms.ConnectionFactory connectionFactory)
      Set the ConnectionFactory to use for the underlying JmsTemplate.
      Since:
      4.1.2
    • getConnectionFactory

      public @Nullable jakarta.jms.ConnectionFactory getConnectionFactory()
      Return the ConnectionFactory that the underlying JmsTemplate uses.
      Since:
      4.1.2
    • setJmsTemplate

      public void setJmsTemplate(@Nullable JmsTemplate jmsTemplate)
      Set the JmsTemplate to use.
    • getJmsTemplate

      public @Nullable JmsTemplate getJmsTemplate()
      Return the configured JmsTemplate.
    • setJmsMessageConverter

      public void setJmsMessageConverter(MessageConverter jmsMessageConverter)
      Set the MessageConverter to use to convert a Message to and from a Message.

      By default, a MessagingMessageConverter is defined using a SimpleMessageConverter to convert the payload of the message.

      Consider configuring a MessagingMessageConverter with a different payload converter for more advanced scenarios.

      See Also:
    • getJmsMessageConverter

      public MessageConverter getJmsMessageConverter()
      Return the MessageConverter to use to convert a Message to and from a Message.
    • setDefaultDestinationName

      public void setDefaultDestinationName(@Nullable String defaultDestinationName)
      Configure the default destination name to use in send methods that don't have a destination argument. If a default destination is not configured, send methods without a destination argument will raise an exception if invoked.
      See Also:
      • AbstractMessageSendingTemplate.setDefaultDestination(Object)
    • getDefaultDestinationName

      public @Nullable String getDefaultDestinationName()
      Return the configured default destination name.
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • send

      public void send(org.springframework.messaging.Message<?> message) throws org.springframework.messaging.MessagingException
      Specified by:
      send in interface org.springframework.messaging.core.MessageSendingOperations<jakarta.jms.Destination>
      Overrides:
      send in class org.springframework.messaging.core.AbstractMessageSendingTemplate<jakarta.jms.Destination>
      Throws:
      org.springframework.messaging.MessagingException
    • convertAndSend

      public void convertAndSend(Object payload, @Nullable Map<String,Object> headers, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
      Specified by:
      convertAndSend in interface org.springframework.messaging.core.MessageSendingOperations<jakarta.jms.Destination>
      Overrides:
      convertAndSend in class org.springframework.messaging.core.AbstractMessageSendingTemplate<jakarta.jms.Destination>
      Throws:
      org.springframework.messaging.MessagingException
    • send

      public void send(String destinationName, org.springframework.messaging.Message<?> message) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Send a message to the given destination.
      Specified by:
      send in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      message - the message to send
      Throws:
      org.springframework.messaging.MessagingException
    • convertAndSend

      public void convertAndSend(String destinationName, Object payload) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message and send it to the given destination.
      Specified by:
      convertAndSend in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      payload - the Object to use as payload
      Throws:
      org.springframework.messaging.MessagingException
    • convertAndSend

      public void convertAndSend(String destinationName, Object payload, @Nullable Map<String,Object> headers) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers and send it to the given destination.
      Specified by:
      convertAndSend in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      payload - the Object to use as payload
      headers - the headers for the message to send
      Throws:
      org.springframework.messaging.MessagingException
    • convertAndSend

      public void convertAndSend(String destinationName, Object payload, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message, apply the given post-processor, and send the resulting message to the given destination.
      Specified by:
      convertAndSend in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      payload - the Object to use as payload
      postProcessor - the post-processor to apply to the message
      Throws:
      org.springframework.messaging.MessagingException
    • convertAndSend

      public void convertAndSend(String destinationName, Object payload, @Nullable Map<String,Object> headers, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers, apply the given post-processor, and send the resulting message to the given destination.
      Specified by:
      convertAndSend in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      payload - the Object to use as payload
      headers - the headers for the message to send
      postProcessor - the post-processor to apply to the message
      Throws:
      org.springframework.messaging.MessagingException
    • receive

      public @Nullable org.springframework.messaging.Message<?> receive() throws org.springframework.messaging.MessagingException
      Specified by:
      receive in interface org.springframework.messaging.core.MessageReceivingOperations<jakarta.jms.Destination>
      Overrides:
      receive in class org.springframework.messaging.core.AbstractMessageReceivingTemplate<jakarta.jms.Destination>
      Throws:
      org.springframework.messaging.MessagingException
    • receiveAndConvert

      public <T> @Nullable T receiveAndConvert(Class<T> targetClass) throws org.springframework.messaging.MessagingException
      Specified by:
      receiveAndConvert in interface org.springframework.messaging.core.MessageReceivingOperations<jakarta.jms.Destination>
      Overrides:
      receiveAndConvert in class org.springframework.messaging.core.AbstractMessageReceivingTemplate<jakarta.jms.Destination>
      Throws:
      org.springframework.messaging.MessagingException
    • receive

      public @Nullable org.springframework.messaging.Message<?> receive(String destinationName) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Receive a message from the given destination.
      Specified by:
      receive in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      Returns:
      the received message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • receiveAndConvert

      public <T> @Nullable T receiveAndConvert(String destinationName, Class<T> targetClass) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Receive a message from the given destination and convert its payload to the specified target class.
      Specified by:
      receiveAndConvert in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      targetClass - the target class to convert the payload to
      Returns:
      the converted payload of the reply message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • receiveSelected

      public @Nullable org.springframework.messaging.Message<?> receiveSelected(@Nullable String messageSelector) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Receive a message from the default destination.
      Specified by:
      receiveSelected in interface JmsMessageOperations
      Parameters:
      messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
      Returns:
      the received message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • receiveSelected

      public @Nullable org.springframework.messaging.Message<?> receiveSelected(jakarta.jms.Destination destination, @Nullable String messageSelector) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Receive a message from the given destination.
      Specified by:
      receiveSelected in interface JmsMessageOperations
      Parameters:
      destination - the target destination
      messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
      Returns:
      the received message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • receiveSelected

      public @Nullable org.springframework.messaging.Message<?> receiveSelected(String destinationName, @Nullable String messageSelector) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Receive a message from the given destination.
      Specified by:
      receiveSelected in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
      Returns:
      the received message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • receiveSelectedAndConvert

      public <T> @Nullable T receiveSelectedAndConvert(@Nullable String messageSelector, Class<T> targetClass) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Receive a message from the default destination and convert its payload to the specified target class.
      Specified by:
      receiveSelectedAndConvert in interface JmsMessageOperations
      Parameters:
      messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
      targetClass - the target class to convert the payload to
      Returns:
      the converted payload of the reply message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • receiveSelectedAndConvert

      public <T> @Nullable T receiveSelectedAndConvert(jakarta.jms.Destination destination, @Nullable String messageSelector, Class<T> targetClass) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Receive a message from the given destination and convert its payload to the specified target class.
      Specified by:
      receiveSelectedAndConvert in interface JmsMessageOperations
      Parameters:
      destination - the target destination
      messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
      targetClass - the target class to convert the payload to
      Returns:
      the converted payload of the reply message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • receiveSelectedAndConvert

      public <T> @Nullable T receiveSelectedAndConvert(String destinationName, @Nullable String messageSelector, Class<T> targetClass) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Receive a message from the given destination and convert its payload to the specified target class.
      Specified by:
      receiveSelectedAndConvert in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      messageSelector - the JMS message selector expression (or null if none). See the JMS specification for a detailed definition of selector expressions.
      targetClass - the target class to convert the payload to
      Returns:
      the converted payload of the reply message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • sendAndReceive

      public @Nullable org.springframework.messaging.Message<?> sendAndReceive(org.springframework.messaging.Message<?> requestMessage) throws org.springframework.messaging.MessagingException
      Specified by:
      sendAndReceive in interface org.springframework.messaging.core.MessageRequestReplyOperations<jakarta.jms.Destination>
      Overrides:
      sendAndReceive in class org.springframework.messaging.core.AbstractMessagingTemplate<jakarta.jms.Destination>
      Throws:
      org.springframework.messaging.MessagingException
    • sendAndReceive

      public @Nullable org.springframework.messaging.Message<?> sendAndReceive(String destinationName, org.springframework.messaging.Message<?> requestMessage) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Send a request message and receive the reply from the given destination.
      Specified by:
      sendAndReceive in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      requestMessage - the message to send
      Returns:
      the reply, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • convertSendAndReceive

      public <T> @Nullable T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Convert the given request Object to serialized form, possibly using a MessageConverter, send it as a Message to the given destination, receive the reply and convert its body of the specified target class.
      Specified by:
      convertSendAndReceive in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      request - payload for the request message to send
      targetClass - the target type to convert the payload of the reply to
      Returns:
      the payload of the reply message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • convertSendAndReceive

      public <T> @Nullable T convertSendAndReceive(Object request, Class<T> targetClass) throws org.springframework.messaging.MessagingException
      Specified by:
      convertSendAndReceive in interface org.springframework.messaging.core.MessageRequestReplyOperations<jakarta.jms.Destination>
      Overrides:
      convertSendAndReceive in class org.springframework.messaging.core.AbstractMessagingTemplate<jakarta.jms.Destination>
      Throws:
      org.springframework.messaging.MessagingException
    • convertSendAndReceive

      public <T> @Nullable T convertSendAndReceive(String destinationName, Object request, @Nullable Map<String,Object> headers, Class<T> targetClass) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Convert the given request Object to serialized form, possibly using a MessageConverter, send it as a Message with the given headers, to the specified destination, receive the reply and convert its body of the specified target class.
      Specified by:
      convertSendAndReceive in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      request - payload for the request message to send
      headers - the headers for the request message to send
      targetClass - the target type to convert the payload of the reply to
      Returns:
      the payload of the reply message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • convertSendAndReceive

      public <T> @Nullable T convertSendAndReceive(Object request, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
      Specified by:
      convertSendAndReceive in interface org.springframework.messaging.core.MessageRequestReplyOperations<jakarta.jms.Destination>
      Overrides:
      convertSendAndReceive in class org.springframework.messaging.core.AbstractMessagingTemplate<jakarta.jms.Destination>
      Throws:
      org.springframework.messaging.MessagingException
    • convertSendAndReceive

      public <T> @Nullable T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor requestPostProcessor) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Convert the given request Object to serialized form, possibly using a MessageConverter, apply the given post-processor and send the resulting Message to the given destination, receive the reply and convert its body of the given target class.
      Specified by:
      convertSendAndReceive in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      request - payload for the request message to send
      targetClass - the target type to convert the payload of the reply to
      requestPostProcessor - post-process to apply to the request message
      Returns:
      the payload of the reply message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • convertSendAndReceive

      public <T> @Nullable T convertSendAndReceive(String destinationName, Object request, @Nullable Map<String,Object> headers, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
      Description copied from interface: JmsMessageOperations
      Convert the given request Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers, apply the given post-processor and send the resulting Message to the specified destination, receive the reply and convert its body of the given target class.
      Specified by:
      convertSendAndReceive in interface JmsMessageOperations
      Parameters:
      destinationName - the name of the target destination
      request - payload for the request message to send
      targetClass - the target type to convert the payload of the reply to
      postProcessor - post-process to apply to the request message
      Returns:
      the payload of the reply message, possibly null if the message could not be received, for example due to a timeout
      Throws:
      org.springframework.messaging.MessagingException
    • convertSendAndReceive

      public <T> @Nullable T convertSendAndReceive(Object request, @Nullable Map<String,Object> headers, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
      Specified by:
      convertSendAndReceive in interface org.springframework.messaging.core.MessageRequestReplyOperations<jakarta.jms.Destination>
      Overrides:
      convertSendAndReceive in class org.springframework.messaging.core.AbstractMessagingTemplate<jakarta.jms.Destination>
      Throws:
      org.springframework.messaging.MessagingException
    • doSend

      protected void doSend(jakarta.jms.Destination destination, org.springframework.messaging.Message<?> message)
      Specified by:
      doSend in class org.springframework.messaging.core.AbstractMessageSendingTemplate<jakarta.jms.Destination>
    • doSend

      protected void doSend(String destinationName, org.springframework.messaging.Message<?> message)
    • doReceive

      protected @Nullable org.springframework.messaging.Message<?> doReceive(jakarta.jms.Destination destination)
      Specified by:
      doReceive in class org.springframework.messaging.core.AbstractMessageReceivingTemplate<jakarta.jms.Destination>
    • doReceive

      protected @Nullable org.springframework.messaging.Message<?> doReceive(String destinationName)
    • doReceiveSelected

      protected @Nullable org.springframework.messaging.Message<?> doReceiveSelected(jakarta.jms.Destination destination, @Nullable String messageSelector)
    • doReceiveSelected

      protected @Nullable org.springframework.messaging.Message<?> doReceiveSelected(String destinationName, @Nullable String messageSelector)
    • doSendAndReceive

      protected @Nullable org.springframework.messaging.Message<?> doSendAndReceive(jakarta.jms.Destination destination, org.springframework.messaging.Message<?> requestMessage)
      Specified by:
      doSendAndReceive in class org.springframework.messaging.core.AbstractMessagingTemplate<jakarta.jms.Destination>
    • doSendAndReceive

      protected @Nullable org.springframework.messaging.Message<?> doSendAndReceive(String destinationName, org.springframework.messaging.Message<?> requestMessage)
    • getRequiredDefaultDestinationName

      protected String getRequiredDefaultDestinationName()
    • convertJmsMessage

      protected @Nullable org.springframework.messaging.Message<?> convertJmsMessage(@Nullable jakarta.jms.Message message)
    • convertJmsException

      protected org.springframework.messaging.MessagingException convertJmsException(JmsException ex)