类 AbstractMessageSendingTemplate<D>
- java.lang.Object
- org.springframework.messaging.core.AbstractMessageSendingTemplate<D>
- 所有已实现的接口:
MessageSendingOperations<D>
public abstract class AbstractMessageSendingTemplate<D> extends Object implements MessageSendingOperations<D>
Abstract base class for implementations ofMessageSendingOperations.- 从以下版本开始:
- 4.0
- 作者:
- Mark Fisher, Rossen Stoyanchev, Stephane Nicoll
字段概要
字段 修饰符和类型 字段 说明 static StringCONVERSION_HINT_HEADERName of the header that can be set to provide further information (e.g. aMethodParameterinstance) about the origin of the payload, to be taken into account as a conversion hint.protected Loglogger
构造器概要
构造器 构造器 说明 AbstractMessageSendingTemplate()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 voidconvertAndSend(D destination, Object payload)Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to the given destination.voidconvertAndSend(D destination, Object payload, Map<String,Object> headers)Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and send it to the given destination.voidconvertAndSend(D destination, Object payload, Map<String,Object> headers, MessagePostProcessor postProcessor)Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post processor, and send the resulting message to the given destination.voidconvertAndSend(D destination, Object payload, MessagePostProcessor postProcessor)Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to the given destination.voidconvertAndSend(Object payload)Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to a default destination.voidconvertAndSend(Object payload, MessagePostProcessor postProcessor)Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to a default destination.protected Message<?>doConvert(Object payload, Map<String,Object> headers, MessagePostProcessor postProcessor)Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and apply the given post processor.protected abstract voiddoSend(D destination, Message<?> message)DgetDefaultDestination()Return the configured default destination.MessageConvertergetMessageConverter()Return the configuredMessageConverter.protected DgetRequiredDefaultDestination()protected Map<String,Object>processHeadersToSend(Map<String,Object> headers)Provides access to the map of input headers before a send operation.voidsend(D destination, Message<?> message)Send a message to the given destination.voidsend(Message<?> message)Send a message to a default destination.voidsetDefaultDestination(D defaultDestination)Configure the default destination to use in send methods that don't have a destination argument.voidsetMessageConverter(MessageConverter messageConverter)Set theMessageConverterto use inconvertAndSendmethods.
字段详细资料
CONVERSION_HINT_HEADER
public static final String CONVERSION_HINT_HEADER
Name of the header that can be set to provide further information (e.g. aMethodParameterinstance) about the origin of the payload, to be taken into account as a conversion hint.- 从以下版本开始:
- 4.2
- 另请参阅:
- 常量字段值
构造器详细资料
AbstractMessageSendingTemplate
public AbstractMessageSendingTemplate()
方法详细资料
setDefaultDestination
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.
getDefaultDestination
public D getDefaultDestination()
Return the configured default destination.
setMessageConverter
public void setMessageConverter(MessageConverter messageConverter)
Set theMessageConverterto use inconvertAndSendmethods.By default,
SimpleMessageConverteris used.- 参数:
messageConverter- the message converter to use
getMessageConverter
public MessageConverter getMessageConverter()
Return the configuredMessageConverter.
send
public void send(Message<?> message)
从接口复制的说明:MessageSendingOperationsSend a message to a default destination.- 指定者:
send在接口中MessageSendingOperations<D>- 参数:
message- the message to send
getRequiredDefaultDestination
protected final D getRequiredDefaultDestination()
send
public void send(D destination, Message<?> message)
从接口复制的说明:MessageSendingOperationsSend a message to the given destination.- 指定者:
send在接口中MessageSendingOperations<D>- 参数:
destination- the target destinationmessage- the message to send
convertAndSend
public void convertAndSend(Object payload) throws MessagingException
从接口复制的说明:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to a default destination.- 指定者:
convertAndSend在接口中MessageSendingOperations<D>- 参数:
payload- the Object to use as payload- 抛出:
MessagingException
convertAndSend
public void convertAndSend(D destination, Object payload) throws MessagingException
从接口复制的说明:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to the given destination.- 指定者:
convertAndSend在接口中MessageSendingOperations<D>- 参数:
destination- the target destinationpayload- the Object to use as payload- 抛出:
MessagingException
convertAndSend
public void convertAndSend(D destination, Object payload, Map<String,Object> headers) throws MessagingException
从接口复制的说明:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and send it to the given destination.- 指定者:
convertAndSend在接口中MessageSendingOperations<D>- 参数:
destination- the target destinationpayload- the Object to use as payloadheaders- headers for the message to send- 抛出:
MessagingException
convertAndSend
public void convertAndSend(Object payload, MessagePostProcessor postProcessor) throws MessagingException
从接口复制的说明:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to a default destination.- 指定者:
convertAndSend在接口中MessageSendingOperations<D>- 参数:
payload- the Object to use as payloadpostProcessor- the post processor to apply to the message- 抛出:
MessagingException
convertAndSend
public void convertAndSend(D destination, Object payload, MessagePostProcessor postProcessor) throws MessagingException
从接口复制的说明:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to the given destination.- 指定者:
convertAndSend在接口中MessageSendingOperations<D>- 参数:
destination- the target destinationpayload- the Object to use as payloadpostProcessor- the post processor to apply to the message- 抛出:
MessagingException
convertAndSend
public void convertAndSend(D destination, Object payload, Map<String,Object> headers, MessagePostProcessor postProcessor) throws MessagingException
从接口复制的说明:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post processor, and send the resulting message to the given destination.- 指定者:
convertAndSend在接口中MessageSendingOperations<D>- 参数:
destination- the target destinationpayload- the Object to use as payloadheaders- headers for the message to sendpostProcessor- the post processor to apply to the message- 抛出:
MessagingException
doConvert
protected Message<?> doConvert(Object payload, Map<String,Object> headers, MessagePostProcessor postProcessor)
Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and apply the given post processor.- 参数:
payload- the Object to use as payloadheaders- headers for the message to sendpostProcessor- the post processor to apply to the message- 返回:
- the converted message
processHeadersToSend
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.
- 参数:
headers- the headers to send (ornullif none)- 返回:
- the actual headers to send (or
nullif none)