Top Description Fields Constructors Methods
org.springframework.messaging.core

public abstract Class AbstractMessageSendingTemplate<D>

extends Object
implements MessageSendingOperations<D>
Class Inheritance
All Implemented Interfaces
org.springframework.messaging.core.MessageSendingOperations
Known Direct Subclasses
org.springframework.messaging.simp.SimpMessagingTemplate, org.springframework.messaging.core.AbstractMessageReceivingTemplate
Type Parameters
<D>
the destination type
Imports
java.util.Map, org.apache.commons.logging.Log, .LogFactory, org.springframework.lang.Nullable, org.springframework.messaging.Message, .MessageHeaders, .MessagingException, org.springframework.messaging.converter.MessageConversionException, .MessageConverter, .SimpleMessageConverter, .SmartMessageConverter, org.springframework.util.Assert

Abstract base class for implementations of MessageSendingOperations.
Authors
Mark Fisher, Rossen Stoyanchev, Stephane Nicoll
Since
4.0

Field Summary

Modifier and TypeField and Description
public static final String
CONVERSION_HINT_HEADER

Name of the header that can be set to provide further information (e.g. a MethodParameter instance) about the origin of the payload, to be taken into account as a conversion hint.

private MessageConverter
private D
protected final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
convertAndSend(Object
the Object to use as payload
payload
)

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message and send it to a default destination.

public void
convertAndSend(D
the target destination
destination
,
Object
the Object to use as payload
payload
)

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message and send it to the given destination.

public void
convertAndSend(D
the target destination
destination
,
Object
the Object to use as payload
payload
,
Map<String, Object>
the headers for the message to send
headers
)

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message with the given headers and send it to the given destination.

public void
convertAndSend(Object
the Object to use as payload
payload
,
MessagePostProcessor
the post processor to apply to the message
postProcessor
)

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to a default destination.

public void
convertAndSend(D
the target destination
destination
,
Object
the Object to use as payload
payload
,
MessagePostProcessor
the post processor to apply to the message
postProcessor
)

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to the given destination.

public void
convertAndSend(D
the target destination
destination
,
Object
the Object to use as payload
payload
,
Map<String, Object>
the headers for the message to send
headers
,
MessagePostProcessor
the post processor to apply to the message
postProcessor
)

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message with the given headers, apply the given post processor, and send the resulting message to the given destination.

protected Message<?>

Returns:

the converted message
doConvert
(Object
the Object to use as payload
payload
,
Map<String, Object>
the headers for the message to send
headers
,
MessagePostProcessor
the post processor to apply to the message
postProcessor
)

Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers and apply the given post processor.

protected abstract void
doSend(D destination, Message<?> message)

public D
getDefaultDestination()

Return the configured default destination.

public MessageConverter
getMessageConverter()

Return the configured MessageConverter.

protected final D
protected Map<String, Object>

Returns:

the actual headers to send (or null if none)
processHeadersToSend
(Map<String, Object>
the headers to send (or null if none)
headers
)

Provides access to the map of input headers before a send operation.

public void
send(Message<?>
the message to send
message
)

Implements org.springframework.messaging.core.MessageSendingOperations.send.

Send a message to a default destination.

public void
send(D
the target destination
destination
,
Message<?>
the message to send
message
)

Implements org.springframework.messaging.core.MessageSendingOperations.send.

Send a message to the given destination.

public void
setDefaultDestination(D defaultDestination)

Configure the default destination to use in send methods that don't have a destination argument.

public void
setMessageConverter(MessageConverter
the message converter to use
messageConverter
)

Set the MessageConverter to use in convertAndSend methods.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONVERSION_HINT_HEADERback to summary
public static final String CONVERSION_HINT_HEADER

Name of the header that can be set to provide further information (e.g. a MethodParameter instance) about the origin of the payload, to be taken into account as a conversion hint.

Since
4.2
converterback to summary
private MessageConverter converter
defaultDestinationback to summary
private D defaultDestination
Annotations
@Nullable
loggerback to summary
protected final Log logger

Constructor Detail

AbstractMessageSendingTemplateback to summary
public AbstractMessageSendingTemplate()

Method Detail

convertAndSendback to summary
public void convertAndSend(Object payload) throws MessagingException

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Doc from org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message and send it to a default destination.

Parameters
payload:Object

the Object to use as payload

Annotations
@Override
convertAndSendback to summary
public void convertAndSend(D destination, Object payload) throws MessagingException

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Doc from org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message and send it to the given destination.

Parameters
destination:D

the target destination

payload:Object

the Object to use as payload

Annotations
@Override
convertAndSendback to summary
public void convertAndSend(D destination, Object payload, Map<String, Object> headers) throws MessagingException

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Doc from org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message with the given headers and send it to the given destination.

Parameters
destination:D

the target destination

payload:Object

the Object to use as payload

headers:Map<String, Object>

the headers for the message to send

Annotations
@Override
convertAndSendback to summary
public void convertAndSend(Object payload, MessagePostProcessor postProcessor) throws MessagingException

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Doc from org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to a default destination.

Parameters
payload:Object

the Object to use as payload

postProcessor:MessagePostProcessor

the post processor to apply to the message

Annotations
@Override
convertAndSendback to summary
public void convertAndSend(D destination, Object payload, MessagePostProcessor postProcessor) throws MessagingException

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Doc from org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to the given destination.

Parameters
destination:D

the target destination

payload:Object

the Object to use as payload

postProcessor:MessagePostProcessor

the post processor to apply to the message

Annotations
@Override
convertAndSendback to summary
public void convertAndSend(D destination, Object payload, Map<String, Object> headers, MessagePostProcessor postProcessor) throws MessagingException

Implements org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Doc from org.springframework.messaging.core.MessageSendingOperations.convertAndSend.

Convert the given Object to serialized form, possibly using a org.springframework.messaging.converter.MessageConverter, wrap it as a message with the given headers, apply the given post processor, and send the resulting message to the given destination.

Parameters
destination:D

the target destination

payload:Object

the Object to use as payload

headers:Map<String, Object>

the headers for the message to send

postProcessor:MessagePostProcessor

the post processor to apply to the message

Annotations
@Override
doConvertback to summary
protected Message<?> doConvert(Object payload, Map<String, Object> headers, MessagePostProcessor postProcessor)

Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers and apply the given post processor.

Parameters
payload:Object

the Object to use as payload

headers:Map<String, Object>

the headers for the message to send

postProcessor:MessagePostProcessor

the post processor to apply to the message

Returns:Message<?>

the converted message

doSendback to summary
protected abstract void doSend(D destination, Message<?> message)
getDefaultDestinationback to summary
public D getDefaultDestination()

Return the configured default destination.

Annotations
@Nullable
getMessageConverterback to summary
public MessageConverter getMessageConverter()

Return the configured MessageConverter.

getRequiredDefaultDestinationback to summary
protected final D getRequiredDefaultDestination()
processHeadersToSendback to summary
protected Map<String, Object> processHeadersToSend(Map<String, Object> headers)

Provides access to the map of input headers before a send operation. Subclasses can modify the headers and then return the same or a different map.

This default implementation in this class returns the input map.

Parameters
headers:Map<String, Object>

the headers to send (or null if none)

Returns:Map<String, Object>

the actual headers to send (or null if none)

Annotations
@Nullable
sendback to summary
public void send(Message<?> message)

Implements org.springframework.messaging.core.MessageSendingOperations.send.

Doc from org.springframework.messaging.core.MessageSendingOperations.send.

Send a message to a default destination.

Parameters
message:Message<?>

the message to send

Annotations
@Override
sendback to summary
public void send(D destination, Message<?> message)

Implements org.springframework.messaging.core.MessageSendingOperations.send.

Doc from org.springframework.messaging.core.MessageSendingOperations.send.

Send a message to the given destination.

Parameters
destination:D

the target destination

message:Message<?>

the message to send

Annotations
@Override
setDefaultDestinationback to summary
public void setDefaultDestination(D defaultDestination)

Configure the default destination 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.

setMessageConverterback to summary
public void setMessageConverter(MessageConverter messageConverter)

Set the MessageConverter to use in convertAndSend methods.

By default, SimpleMessageConverter is used.

Parameters
messageConverter:MessageConverter

the message converter to use