org.springframework.messaging.core

## Class GenericMessagingTemplate

- java.lang.Object
- - org.springframework.messaging.core.AbstractMessageSendingTemplate<D>
  - - org.springframework.messaging.core.AbstractMessagingTemplate<D>
    - - org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate<MessageChannel>
      - - org.springframework.messaging.core.GenericMessagingTemplate

- All Implemented Interfaces:
    Aware, BeanFactoryAware, DestinationResolvingMessageReceivingOperations<MessageChannel>, DestinationResolvingMessageRequestReplyOperations<MessageChannel>, DestinationResolvingMessageSendingOperations<MessageChannel>, MessageReceivingOperations<MessageChannel>, MessageRequestReplyOperations<MessageChannel>, MessageSendingOperations<MessageChannel>

      public class GenericMessagingTemplate
      extends AbstractDestinationResolvingMessagingTemplate<MessageChannel>
      implements BeanFactoryAware

  A messaging template that resolves destinations names to `MessageChannel`'s to send and receive messages from.
  Since:
    4.0
  Author:
    Mark Fisher, Rossen Stoyanchev

- - ### Field Summary

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

      `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenericMessagingTemplate()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Message<?>` | `doReceive(MessageChannel channel)`
    `protected void` | `doSend(MessageChannel channel, Message<?> message)`
    `protected Message<?>` | `doSendAndReceive(MessageChannel channel, Message<?> requestMessage)`
    `long` | `getReceiveTimeout()` Return the configured receive operation timeout value.
    `long` | `getSendTimeout()` Return the configured send operation timeout value.
    `void` | `setBeanFactory(BeanFactory beanFactory)` Callback that supplies the owning factory to a bean instance.
    `void` | `setReceiveTimeout(long receiveTimeout)` Configure the timeout value to use for receive operations.
    `void` | `setSendTimeout(long sendTimeout)` Configure the timeout value to use for send operations.
    `void` | `setThrowExceptionOnLateReply(boolean throwExceptionOnLateReply)` Whether the thread sending a reply should have an exception raised if the receiving thread isn't going to receive the reply either because it timed out, or because it already received a reply, or because it got an exception while sending the request message.

    - ### Methods inherited from class org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate

      `convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, getDestinationResolver, receive, receiveAndConvert, resolveDestination, send, sendAndReceive, setDestinationResolver`

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

      `convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, receive, receive, receiveAndConvert, receiveAndConvert, sendAndReceive, sendAndReceive`

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

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

    - ### Methods inherited from class java.lang.Object

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

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

      `convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, send, send`

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

      `receive, receive, receiveAndConvert, receiveAndConvert`

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

      `convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive, sendAndReceive`

- - ### Constructor Detail

    - #### GenericMessagingTemplate

          public GenericMessagingTemplate()

  - ### Method Detail

    - #### setSendTimeout

          public void setSendTimeout(long sendTimeout)

      Configure the timeout value to use for send operations.
      Parameters:
        `sendTimeout` - the send timeout in milliseconds

    - #### getSendTimeout

          public long getSendTimeout()

      Return the configured send operation timeout value.

    - #### setReceiveTimeout

          public void setReceiveTimeout(long receiveTimeout)

      Configure the timeout value to use for receive operations.
      Parameters:
        `receiveTimeout` - the receive timeout in milliseconds

    - #### getReceiveTimeout

          public long getReceiveTimeout()

      Return the configured receive operation timeout value.

    - #### setThrowExceptionOnLateReply

          public void setThrowExceptionOnLateReply(boolean throwExceptionOnLateReply)

      Whether the thread sending a reply should have an exception raised if the receiving thread isn't going to receive the reply either because it timed out, or because it already received a reply, or because it got an exception while sending the request message.

      The default value is `false` in which case only a WARN message is logged. If set to `true` a `MessageDeliveryException` is raised in addition to the log message.

      Parameters:
        `throwExceptionOnLateReply` - whether to throw an exception or not

    - #### setBeanFactory

          public void setBeanFactory(BeanFactory beanFactory)
                              throws BeansException

      Description copied from interface: `BeanFactoryAware`
      Callback that supplies the owning factory to a bean instance.

      Invoked after the population of normal bean properties but before an initialization callback such as `InitializingBean.afterPropertiesSet()` or a custom init-method.

      Specified by:
        `setBeanFactory` in interface `BeanFactoryAware`
      Parameters:
        `beanFactory` - owning BeanFactory (never `null`). The bean can immediately call methods on the factory.
      Throws:
        `BeansException` - in case of initialization errors
      See Also:
        `BeanInitializationException`

    - #### doSend

          protected final void doSend(MessageChannel channel,
                                      Message<?> message)

      Specified by:
        `doSend` in class `AbstractMessageSendingTemplate<MessageChannel>`

    - #### doReceive

          protected final Message<?> doReceive(MessageChannel channel)

      Specified by:
        `doReceive` in class `AbstractMessagingTemplate<MessageChannel>`

    - #### doSendAndReceive

          protected final Message<?> doSendAndReceive(MessageChannel channel,
                                                      Message<?> requestMessage)

      Specified by:
        `doSendAndReceive` in class `AbstractMessagingTemplate<MessageChannel>`