org.springframework.messaging.core

## Class AbstractDestinationResolvingMessagingTemplate<D>

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

Type Parameters:
  `D` - the destination type

All Implemented Interfaces:
  DestinationResolvingMessageReceivingOperations<D>, DestinationResolvingMessageRequestReplyOperations<D>, DestinationResolvingMessageSendingOperations<D>, MessageReceivingOperations<D>, MessageRequestReplyOperations<D>, MessageSendingOperations<D>

Direct Known Subclasses:
  GenericMessagingTemplate

    public abstract class AbstractDestinationResolvingMessagingTemplate<D>
    extends AbstractMessagingTemplate<D>
    implements DestinationResolvingMessageSendingOperations<D>, DestinationResolvingMessageReceivingOperations<D>, DestinationResolvingMessageRequestReplyOperations<D>

An extension of `AbstractMessagingTemplate` that adds operations for sending messages to a resolvable destination name. Supports destination resolving as defined by the following interfaces:

- `DestinationResolvingMessageSendingOperations`
- `DestinationResolvingMessageReceivingOperations`
- `DestinationResolvingMessageRequestReplyOperations`

Since:
  4.0
Author:
  Mark Fisher, Rossen Stoyanchev

### Field Summary

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

`CONVERSION_HINT_HEADER, logger`

### Constructor Summary

Constructors
Constructor and Description
`AbstractDestinationResolvingMessagingTemplate()`

### Method Summary

All Methods Instance Methods Concrete Methods
`<T> void` `convertAndSend(String destinationName, T payload)` Resolve the given destination name to a destination, convert the payload Object to serialized form, possibly using a `MessageConverter`, wrap it as a message and send it to the resolved destination.
`<T> void` `convertAndSend(String destinationName, T payload, Map<String,Object> headers)` Resolve the given destination name to a destination, convert the payload Object to serialized form, possibly using a `MessageConverter`, wrap it as a message with the given headers and send it to the resolved destination.
`<T> void` `convertAndSend(String destinationName, T payload, Map<String,Object> headers, MessagePostProcessor postProcessor)` Resolve the given destination name to a destination, convert the payload 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 resolved destination.
`<T> void` `convertAndSend(String destinationName, T payload, MessagePostProcessor postProcessor)` Resolve the given destination name to a destination, convert the payload 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 resolved destination.
`<T> T` `convertSendAndReceive(String destinationName, Object request, Class<T> targetClass)` Resolve the given destination name, convert the payload request Object to serialized form, possibly using a `MessageConverter`, wrap it as a message and send it to the resolved destination, receive a reply and convert its body to the specified target class.

`<T> T`

`convertSendAndReceive(String destinationName, Object request, Class<T> targetClass, MessagePostProcessor postProcessor)`
Resolve the given destination name, convert the payload request Object to serialized form, possibly using a `MessageConverter`, wrap it as a message, apply the given post process, and send the resulting message to the resolved destination, then receive a reply and convert its body to the specified target class.

`<T> T`

`convertSendAndReceive(String destinationName, Object request, Map<String,Object> headers, Class<T> targetClass)`
Resolve the given destination name, convert the payload request Object to serialized form, possibly using a `MessageConverter`, wrap it as a message with the given headers and send it to the resolved destination, receive a reply and convert its body to the specified target class.

`<T> T`

`convertSendAndReceive(String destinationName, Object request, Map<String,Object> headers, Class<T> targetClass, MessagePostProcessor postProcessor)`
Resolve the given destination name, convert the payload request Object to serialized form, possibly using a `MessageConverter`, wrap it as a message with the given headers, apply the given post process, and send the resulting message to the resolved destination, then receive a reply and convert its body to the specified target class.

`DestinationResolver<D>` `getDestinationResolver()` Return the configured destination resolver.
`Message<?>` `receive(String destinationName)` Resolve the given destination name and receive a message from it.
`<T> T` `receiveAndConvert(String destinationName, Class<T> targetClass)` Resolve the given destination name, receive a message from it, convert the payload to the specified target type.
`protected D` `resolveDestination(String destinationName)`
`void` `send(String destinationName, Message<?> message)` Resolve the given destination name to a destination and send a message to it.
`Message<?>` `sendAndReceive(String destinationName, Message<?> requestMessage)` Resolve the given destination name to a destination and send the given message, receive a reply and return it.
`void` `setDestinationResolver(DestinationResolver<D> destinationResolver)` Configure the `DestinationResolver` to use to resolve String destination names into actual destinations of type `<D>`.

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

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

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

`doConvert, doReceive, receive, receive, receiveAndConvert, receiveAndConvert`

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

`convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, doSend, 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

#### AbstractDestinationResolvingMessagingTemplate

    public AbstractDestinationResolvingMessagingTemplate()

### Method Detail

#### setDestinationResolver

    public void setDestinationResolver(@Nullable
                                       DestinationResolver<D> destinationResolver)

Configure the `DestinationResolver` to use to resolve String destination names into actual destinations of type `<D>`.

This field does not have a default setting. If not configured, methods that require resolving a destination name will raise an `IllegalArgumentException`.

Parameters:
  `destinationResolver` - the destination resolver to use

#### getDestinationResolver

    @Nullable
    public DestinationResolver<D> getDestinationResolver()

Return the configured destination resolver.

#### send

    public void send(String destinationName,
                     Message<?> message)

Description copied from interface: `DestinationResolvingMessageSendingOperations`
Resolve the given destination name to a destination and send a message to it.

Specified by:
  `send` in interface `DestinationResolvingMessageSendingOperations<D>`
Parameters:
  `destinationName` - the destination name to resolve
  `message` - the message to send

#### resolveDestination

    protected final D resolveDestination(String destinationName)

#### convertAndSend

    public <T> void convertAndSend(String destinationName,
                                   T payload)

Description copied from interface: `DestinationResolvingMessageSendingOperations`
Resolve the given destination name to a destination, convert the payload Object to serialized form, possibly using a `MessageConverter`, wrap it as a message and send it to the resolved destination.

Specified by:
  `convertAndSend` in interface `DestinationResolvingMessageSendingOperations<D>`
Parameters:
  `destinationName` - the destination name to resolve
  `payload` - the Object to use as payload

#### convertAndSend

    public <T> void convertAndSend(String destinationName,
                                   T payload,
                                   @Nullable
                                   Map<String,Object> headers)

Description copied from interface: `DestinationResolvingMessageSendingOperations`
Resolve the given destination name to a destination, convert the payload Object to serialized form, possibly using a `MessageConverter`, wrap it as a message with the given headers and send it to the resolved destination.

Specified by:
  `convertAndSend` in interface `DestinationResolvingMessageSendingOperations<D>`
Parameters:
  `destinationName` - the destination name to resolve
  `payload` - the Object to use as payload
  `headers` - the headers for the message to send

#### convertAndSend

    public <T> void convertAndSend(String destinationName,
                                   T payload,
                                   @Nullable
                                   MessagePostProcessor postProcessor)

Description copied from interface: `DestinationResolvingMessageSendingOperations`
Resolve the given destination name to a destination, convert the payload 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 resolved destination.

Specified by:
  `convertAndSend` in interface `DestinationResolvingMessageSendingOperations<D>`
Parameters:
  `destinationName` - the destination name to resolve
  `payload` - the Object to use as payload
  `postProcessor` - the post processor to apply to the message

#### convertAndSend

    public <T> void convertAndSend(String destinationName,
                                   T payload,
                                   @Nullable
                                   Map<String,Object> headers,
                                   @Nullable
                                   MessagePostProcessor postProcessor)

Description copied from interface: `DestinationResolvingMessageSendingOperations`
Resolve the given destination name to a destination, convert the payload 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 resolved destination.

Specified by:
  `convertAndSend` in interface `DestinationResolvingMessageSendingOperations<D>`
Parameters:
  `destinationName` - the destination name to resolve
  `payload` - the Object to use as payload
  `headers` - the headers for the message to send
  `postProcessor` - the post processor to apply to the message

#### receive

    @Nullable
    public Message<?> receive(String destinationName)

Description copied from interface: `DestinationResolvingMessageReceivingOperations`
Resolve the given destination name and receive a message from it.

Specified by:
  `receive` in interface `DestinationResolvingMessageReceivingOperations<D>`
Parameters:
  `destinationName` - the destination name to resolve

#### receiveAndConvert

    @Nullable
    public <T> T receiveAndConvert(String destinationName,
                                             Class<T> targetClass)

Description copied from interface: `DestinationResolvingMessageReceivingOperations`
Resolve the given destination name, receive a message from it, convert the payload to the specified target type.

Specified by:
  `receiveAndConvert` in interface `DestinationResolvingMessageReceivingOperations<D>`
Parameters:
  `destinationName` - the destination name to resolve
  `targetClass` - the target class for the converted payload

#### sendAndReceive

    @Nullable
    public Message<?> sendAndReceive(String destinationName,
                                               Message<?> requestMessage)

Description copied from interface: `DestinationResolvingMessageRequestReplyOperations`
Resolve the given destination name to a destination and send the given message, receive a reply and return it.

Specified by:
  `sendAndReceive` in interface `DestinationResolvingMessageRequestReplyOperations<D>`
Parameters:
  `destinationName` - the name of the target destination
  `requestMessage` - the message to send
Returns:
  the received message, possibly `null` if the message could not be received, for example due to a timeout

#### convertSendAndReceive

    @Nullable
    public <T> T convertSendAndReceive(String destinationName,
                                                 Object request,
                                                 Class<T> targetClass)

Description copied from interface: `DestinationResolvingMessageRequestReplyOperations`
Resolve the given destination name, convert the payload request Object to serialized form, possibly using a `MessageConverter`, wrap it as a message and send it to the resolved destination, receive a reply and convert its body to the specified target class.

Specified by:
  `convertSendAndReceive` in interface `DestinationResolvingMessageRequestReplyOperations<D>`
Parameters:
  `destinationName` - the name of the target destination
  `request` - the payload for the request message to send
  `targetClass` - the target class to convert the payload of the reply to
Returns:
  the converted payload of the reply message, possibly `null` if the message could not be received, for example due to a timeout

#### convertSendAndReceive

    @Nullable
    public <T> T convertSendAndReceive(String destinationName,
                                                 Object request,
                                                 @Nullable
                                                 Map<String,Object> headers,
                                                 Class<T> targetClass)

Description copied from interface: `DestinationResolvingMessageRequestReplyOperations`
Resolve the given destination name, convert the payload request Object to serialized form, possibly using a `MessageConverter`, wrap it as a message with the given headers and send it to the resolved destination, receive a reply and convert its body to the specified target class.

Specified by:
  `convertSendAndReceive` in interface `DestinationResolvingMessageRequestReplyOperations<D>`
Parameters:
  `destinationName` - the name of the target destination
  `request` - the payload for the request message to send
  `headers` - the headers for the request message to send
  `targetClass` - the target class to convert the payload of the reply to
Returns:
  the converted payload of the reply message, possibly `null` if the message could not be received, for example due to a timeout

#### convertSendAndReceive

    @Nullable
    public <T> T convertSendAndReceive(String destinationName,
                                                 Object request,
                                                 Class<T> targetClass,
                                                 @Nullable
                                                 MessagePostProcessor postProcessor)

Description copied from interface: `DestinationResolvingMessageRequestReplyOperations`
Resolve the given destination name, convert the payload request Object to serialized form, possibly using a `MessageConverter`, wrap it as a message, apply the given post process, and send the resulting message to the resolved destination, then receive a reply and convert its body to the specified target class.

Specified by:
  `convertSendAndReceive` in interface `DestinationResolvingMessageRequestReplyOperations<D>`
Parameters:
  `destinationName` - the name of the target destination
  `request` - the payload for the request message to send
  `targetClass` - the target class to convert the payload of the reply to
  `postProcessor` - post process for the request message
Returns:
  the converted payload of the reply message, possibly `null` if the message could not be received, for example due to a timeout

#### convertSendAndReceive

    @Nullable
    public <T> T convertSendAndReceive(String destinationName,
                                                 Object request,
                                                 @Nullable
                                                 Map<String,Object> headers,
                                                 Class<T> targetClass,
                                                 @Nullable
                                                 MessagePostProcessor postProcessor)

Description copied from interface: `DestinationResolvingMessageRequestReplyOperations`
Resolve the given destination name, convert the payload request Object to serialized form, possibly using a `MessageConverter`, wrap it as a message with the given headers, apply the given post process, and send the resulting message to the resolved destination, then receive a reply and convert its body to the specified target class.

Specified by:
  `convertSendAndReceive` in interface `DestinationResolvingMessageRequestReplyOperations<D>`
Parameters:
  `destinationName` - the name of the target destination
  `request` - the payload for the request message to send
  `headers` - the headers for the request message to send
  `targetClass` - the target class to convert the payload of the reply to
  `postProcessor` - post process for the request message
Returns:
  the converted payload of the reply message, possibly `null` if the message could not be received, for example due to a timeout