类 GenericMessagingTemplate
- 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<MessageChannel>
- org.springframework.messaging.core.GenericMessagingTemplate
- 所有已实现的接口:
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 toMessageChannel
's to send and receive messages from.- 从以下版本开始:
- 4.0
- 作者:
- Mark Fisher, Rossen Stoyanchev, Gary Russell
字段概要
字段 修饰符和类型 字段 说明 static String
DEFAULT_RECEIVE_TIMEOUT_HEADER
The default header key used for a receive timeout.static String
DEFAULT_SEND_TIMEOUT_HEADER
The default header key used for a send timeout.从类继承的字段 org.springframework.messaging.core.AbstractMessageSendingTemplate
CONVERSION_HINT_HEADER, logger
构造器概要
构造器 构造器 说明 GenericMessagingTemplate()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Message<?>
doReceive(MessageChannel channel)
Actually receive a message from the given destination.protected Message<?>
doReceive(MessageChannel channel, long timeout)
protected void
doSend(MessageChannel channel, Message<?> message)
protected void
doSend(MessageChannel channel, Message<?> message, long timeout)
protected Message<?>
doSendAndReceive(MessageChannel channel, Message<?> requestMessage)
long
getReceiveTimeout()
Return the configured receive operation timeout value.String
getReceiveTimeoutHeader()
Return the configured receive-timeout header.long
getSendTimeout()
Return the configured default send operation timeout value.String
getSendTimeoutHeader()
Return the configured send-timeout header.void
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.void
setReceiveTimeout(long receiveTimeout)
Configure the default timeout value to use for receive operations.void
setReceiveTimeoutHeader(String receiveTimeoutHeader)
Set the name of the header used to determine the send timeout (if present).void
setSendTimeout(long sendTimeout)
Configure the default timeout value to use for send operations.void
setSendTimeoutHeader(String sendTimeoutHeader)
Set the name of the header used to determine the send timeout (if present).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.从类继承的方法 org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, getDestinationResolver, receive, receiveAndConvert, resolveDestination, send, sendAndReceive, setDestinationResolver
从类继承的方法 org.springframework.messaging.core.AbstractMessagingTemplate
convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive, sendAndReceive
从类继承的方法 org.springframework.messaging.core.AbstractMessageReceivingTemplate
doConvert, receive, receive, receiveAndConvert, receiveAndConvert
从类继承的方法 org.springframework.messaging.core.AbstractMessageSendingTemplate
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, send, setDefaultDestination, setMessageConverter
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.messaging.core.MessageReceivingOperations
receive, receive, receiveAndConvert, receiveAndConvert
从接口继承的方法 org.springframework.messaging.core.MessageRequestReplyOperations
convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive, sendAndReceive
从接口继承的方法 org.springframework.messaging.core.MessageSendingOperations
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, send, send
字段详细资料
DEFAULT_SEND_TIMEOUT_HEADER
public static final String DEFAULT_SEND_TIMEOUT_HEADER
The default header key used for a send timeout.- 另请参阅:
- 常量字段值
DEFAULT_RECEIVE_TIMEOUT_HEADER
public static final String DEFAULT_RECEIVE_TIMEOUT_HEADER
The default header key used for a receive timeout.- 另请参阅:
- 常量字段值
构造器详细资料
GenericMessagingTemplate
public GenericMessagingTemplate()
方法详细资料
setSendTimeout
public void setSendTimeout(long sendTimeout)
Configure the default timeout value to use for send operations. May be overridden for individual messages.- 参数:
sendTimeout
- the send timeout in milliseconds- 另请参阅:
setSendTimeoutHeader(String)
getSendTimeout
public long getSendTimeout()
Return the configured default send operation timeout value.
setReceiveTimeout
public void setReceiveTimeout(long receiveTimeout)
Configure the default timeout value to use for receive operations. May be overridden for individual messages when using sendAndReceive operations.- 参数:
receiveTimeout
- the receive timeout in milliseconds- 另请参阅:
setReceiveTimeoutHeader(String)
getReceiveTimeout
public long getReceiveTimeout()
Return the configured receive operation timeout value.
setSendTimeoutHeader
public void setSendTimeoutHeader(String sendTimeoutHeader)
Set the name of the header used to determine the send timeout (if present). Default "sendTimeout".The header is removed before sending the message to avoid propagation.
- 从以下版本开始:
- 5.0
getSendTimeoutHeader
public String getSendTimeoutHeader()
Return the configured send-timeout header.- 从以下版本开始:
- 5.0
setReceiveTimeoutHeader
public void setReceiveTimeoutHeader(String receiveTimeoutHeader)
Set the name of the header used to determine the send timeout (if present). Default "receiveTimeout". The header is removed before sending the message to avoid propagation.- 从以下版本开始:
- 5.0
getReceiveTimeoutHeader
public String getReceiveTimeoutHeader()
Return the configured receive-timeout header.- 从以下版本开始:
- 5.0
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 totrue
aMessageDeliveryException
is raised in addition to the log message.- 参数:
throwExceptionOnLateReply
- whether to throw an exception or not
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
从接口复制的说明: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.- 指定者:
setBeanFactory
在接口中BeanFactoryAware
- 参数:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- 抛出:
BeansException
- in case of initialization errors- 另请参阅:
BeanInitializationException
doSend
protected final void doSend(MessageChannel channel, Message<?> message)
doSend
protected final void doSend(MessageChannel channel, Message<?> message, long timeout)
doReceive
@Nullable protected final Message<?> doReceive(MessageChannel channel)
从类复制的说明:AbstractMessageReceivingTemplate
Actually receive a message from the given destination.- 指定者:
doReceive
在类中AbstractMessageReceivingTemplate<MessageChannel>
- 参数:
channel
- the target destination- 返回:
- the received message, possibly
null
if the message could not be received, for example due to a timeout
doReceive
@Nullable protected final Message<?> doReceive(MessageChannel channel, long timeout)
doSendAndReceive
@Nullable protected final Message<?> doSendAndReceive(MessageChannel channel, Message<?> requestMessage)