|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.integration.core.MessagingTemplate
public class MessagingTemplate
This is the central class for invoking message exchange operations across
MessageChannel
s. It supports one-way send and receive calls as well
as request/reply.
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
---|---|
MessagingTemplate()
Create a MessagingTemplate with no default channel. |
|
MessagingTemplate(MessageChannel defaultChannel)
Create a MessagingTemplate with the given default channel. |
Method Summary | ||
---|---|---|
void |
afterPropertiesSet()
|
|
|
convertAndSend(MessageChannel channel,
T object)
Send the given object to the specified channel, converting the object to a message with a configured MessageConverter. |
|
|
convertAndSend(MessageChannel channel,
T object,
MessagePostProcessor postProcessor)
Send the given object to the specified channel, converting the object to a message with a configured MessageConverter. |
|
|
convertAndSend(java.lang.String channelName,
T object)
Send the given object to the specified channel, converting the object to a message with a configured MessageConverter. |
|
|
convertAndSend(java.lang.String channelName,
T object,
MessagePostProcessor postProcessor)
Send the given object to the specified channel, converting the object to a message with a configured MessageConverter. |
|
|
convertAndSend(T object)
Send the given object to the default channel, converting the object to a message with a configured MessageConverter. |
|
|
convertAndSend(T object,
MessagePostProcessor postProcessor)
Send the given object to the default channel, converting the object to a message with a configured MessageConverter. |
|
java.lang.Object |
convertSendAndReceive(MessageChannel channel,
java.lang.Object request)
Send the given request object to the specified channel, converting the object to a message with a configured MessageConverter. |
|
java.lang.Object |
convertSendAndReceive(MessageChannel channel,
java.lang.Object request,
MessagePostProcessor requestPostProcessor)
Send the given request object to the specified channel, converting the object to a message with a configured MessageConverter. |
|
java.lang.Object |
convertSendAndReceive(java.lang.Object request)
Send the given request object to the default channel, converting the object to a message with a configured MessageConverter. |
|
java.lang.Object |
convertSendAndReceive(java.lang.Object request,
MessagePostProcessor requestPostProcessor)
Send the given request object to the default channel, converting the object to a message with a configured MessageConverter. |
|
java.lang.Object |
convertSendAndReceive(java.lang.String channelName,
java.lang.Object request)
Send the given request object to the specified channel, converting the object to a message with a configured MessageConverter. |
|
java.lang.Object |
convertSendAndReceive(java.lang.String channelName,
java.lang.Object request,
MessagePostProcessor requestPostProcessor)
Send the given request object to the specified channel, converting the object to a message with a configured MessageConverter. |
|
|
receive()
Receive a message synchronously from the default channel, but only wait up to a specified time for delivery. |
|
|
receive(PollableChannel channel)
Receive a message synchronously from the specified channel, but only wait up to a specified time for delivery. |
|
|
receive(java.lang.String channelName)
Receive a message synchronously from the specified channel, but only wait up to a specified time for delivery. |
|
java.lang.Object |
receiveAndConvert()
Receive a message synchronously from the default channel, but only wait up to a specified time for delivery. |
|
java.lang.Object |
receiveAndConvert(PollableChannel channel)
Receive a message synchronously from the specified channel, but only wait up to a specified time for delivery. |
|
java.lang.Object |
receiveAndConvert(java.lang.String channelName)
Receive a message synchronously from the specified channel, but only wait up to a specified time for delivery. |
|
protected MessageChannel |
resolveChannelName(java.lang.String channelName)
Resolve the given channel name into a MessageChannel ,
via this template's ChannelResolver if available. |
|
|
send(Message<P> message)
Send a message to the default channel. |
|
|
send(MessageChannel channel,
Message<P> message)
Send a message to the specified channel. |
|
|
send(java.lang.String channelName,
Message<P> message)
Send a message to the specified channel. |
|
Message<?> |
sendAndReceive(Message<?> requestMessage)
Send a message to the default channel and receive a reply. |
|
Message<?> |
sendAndReceive(MessageChannel channel,
Message<?> requestMessage)
Send a message to the specified channel and receive a reply. |
|
Message<?> |
sendAndReceive(java.lang.String channelName,
Message<?> requestMessage)
Send a message to the specified channel and receive a reply. |
|
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
|
|
void |
setChannelResolver(ChannelResolver channelResolver)
Set the ChannelResolver that is to be used to resolve
MessageChannel references for this template. |
|
void |
setDefaultChannel(MessageChannel defaultChannel)
Specify the default MessageChannel to use when invoking the send and/or receive methods that do not expect a channel parameter. |
|
void |
setMessageConverter(MessageConverter messageConverter)
Set the MessageConverter that is to be used to convert
between Messages and objects for this template. |
|
void |
setReceiveTimeout(long receiveTimeout)
Specify the timeout value to use for receive operations. |
|
void |
setSendTimeout(long sendTimeout)
Specify the timeout value to use for send operations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log logger
Constructor Detail |
---|
public MessagingTemplate()
setDefaultChannel(MessageChannel)
.
public MessagingTemplate(MessageChannel defaultChannel)
Method Detail |
---|
public void setDefaultChannel(MessageChannel defaultChannel)
public void setChannelResolver(ChannelResolver channelResolver)
ChannelResolver
that is to be used to resolve
MessageChannel
references for this template.
When running within an application context, the default resolver is a
BeanFactoryChannelResolver
.
public void setMessageConverter(MessageConverter messageConverter)
MessageConverter
that is to be used to convert
between Messages and objects for this template.
The default is SimpleMessageConverter
.
public void setSendTimeout(long sendTimeout)
sendTimeout
- the send timeout in millisecondspublic void setReceiveTimeout(long receiveTimeout)
receiveTimeout
- the receive timeout in millisecondspublic void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
setBeanFactory
in interface org.springframework.beans.factory.BeanFactoryAware
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public <P> void send(Message<P> message)
MessagingOperations
This will only work with a default channel specified!
send
in interface MessagingOperations
message
- the message to sendpublic <P> void send(MessageChannel channel, Message<P> message)
MessagingOperations
send
in interface MessagingOperations
channel
- the channel to which the message will be sentmessage
- the message to sendpublic <P> void send(java.lang.String channelName, Message<P> message)
MessagingOperations
send
in interface MessagingOperations
channelName
- the name of the channel to which the message will be sent
(to be resolved to an actual channel by a ChannelResolver)message
- the message to sendpublic <T> void convertAndSend(T object)
MessagingOperations
This will only work with a default channel specified!
convertAndSend
in interface MessagingOperations
object
- the object to convert to a messagepublic <T> void convertAndSend(MessageChannel channel, T object)
MessagingOperations
convertAndSend
in interface MessagingOperations
channel
- the channel to send this message toobject
- the object to convert to a messagepublic <T> void convertAndSend(java.lang.String channelName, T object)
MessagingOperations
convertAndSend
in interface MessagingOperations
channelName
- the name of the channel to send this message to
(to be resolved to an actual channel by a ChannelResolver)object
- the object to convert to a messagepublic <T> void convertAndSend(T object, MessagePostProcessor postProcessor)
MessagingOperations
This will only work with a default channel specified!
convertAndSend
in interface MessagingOperations
object
- the object to convert to a messagepostProcessor
- the callback to modify the messagepublic <T> void convertAndSend(MessageChannel channel, T object, MessagePostProcessor postProcessor)
MessagingOperations
convertAndSend
in interface MessagingOperations
channel
- the channel to which the message will be sentobject
- the object to convert to a messagepostProcessor
- the callback to modify the messagepublic <T> void convertAndSend(java.lang.String channelName, T object, MessagePostProcessor postProcessor)
MessagingOperations
convertAndSend
in interface MessagingOperations
channelName
- the name of the channel to which the message will be sent
(to be resolved to an actual channel by a ChannelResolver)object
- the object to convert to a messagepostProcessor
- the callback to modify the messagepublic <P> Message<P> receive()
MessagingOperations
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
This will only work with a default channel specified!
receive
in interface MessagingOperations
null
if the timeout expirespublic <P> Message<P> receive(PollableChannel channel)
MessagingOperations
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
receive
in interface MessagingOperations
channel
- the channel from which a message should be received
null
if the timeout expirespublic <P> Message<P> receive(java.lang.String channelName)
MessagingOperations
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
receive
in interface MessagingOperations
channelName
- the name of the channel from which a message should be received
(to be resolved to an actual channel by a ChannelResolver)
null
if the timeout expirespublic java.lang.Object receiveAndConvert() throws MessagingException
MessagingOperations
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
This will only work with a default channel specified!
receiveAndConvert
in interface MessagingOperations
null
if the timeout expires.
MessagingException
- if an error occurs during message receptionpublic java.lang.Object receiveAndConvert(PollableChannel channel) throws MessagingException
MessagingOperations
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
receiveAndConvert
in interface MessagingOperations
channel
- the channel from which a message should be received
null
if the timeout expires.
MessagingException
- if an error occurs during message receptionpublic java.lang.Object receiveAndConvert(java.lang.String channelName) throws MessagingException
MessagingOperations
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
receiveAndConvert
in interface MessagingOperations
channelName
- the name of the channel from which a message should be received
(to be resolved to an actual channel by a ChannelResolver)
null
if the timeout expires.
MessagingException
- if an error occurs during message receptionpublic Message<?> sendAndReceive(Message<?> requestMessage)
MessagingOperations
This will only work with a default channel specified!
sendAndReceive
in interface MessagingOperations
requestMessage
- the message to send
public Message<?> sendAndReceive(MessageChannel channel, Message<?> requestMessage)
MessagingOperations
sendAndReceive
in interface MessagingOperations
channel
- the channel to which the request Message will be sentrequestMessage
- the message to send
public Message<?> sendAndReceive(java.lang.String channelName, Message<?> requestMessage)
MessagingOperations
sendAndReceive
in interface MessagingOperations
channelName
- the name of the channel to which the request Message will be sent
(to be resolved to an actual channel by a ChannelResolver)requestMessage
- the message to send
public java.lang.Object convertSendAndReceive(java.lang.Object request)
MessagingOperations
This will only work with a default channel specified!
convertSendAndReceive
in interface MessagingOperations
request
- the object to convert to a request message
public java.lang.Object convertSendAndReceive(MessageChannel channel, java.lang.Object request)
MessagingOperations
convertSendAndReceive
in interface MessagingOperations
channel
- the channel to which the request message will be sentrequest
- the object to convert to a request message
public java.lang.Object convertSendAndReceive(java.lang.String channelName, java.lang.Object request)
MessagingOperations
convertSendAndReceive
in interface MessagingOperations
channelName
- the name of the channel to which the request message will be sent
(to be resolved to an actual channel by a ChannelResolver)request
- the object to convert to a request message
public java.lang.Object convertSendAndReceive(java.lang.Object request, MessagePostProcessor requestPostProcessor)
MessagingOperations
This will only work with a default channel specified!
convertSendAndReceive
in interface MessagingOperations
request
- the object to convert to a request messagerequestPostProcessor
- the callback to modify the request message
public java.lang.Object convertSendAndReceive(MessageChannel channel, java.lang.Object request, MessagePostProcessor requestPostProcessor)
MessagingOperations
convertSendAndReceive
in interface MessagingOperations
channel
- the channel to which the request message will be sentrequest
- the object to convert to a request messagerequestPostProcessor
- the callback to modify the request message
public java.lang.Object convertSendAndReceive(java.lang.String channelName, java.lang.Object request, MessagePostProcessor requestPostProcessor)
MessagingOperations
convertSendAndReceive
in interface MessagingOperations
channelName
- the name of the channel to which the request message will be sent
(to be resolved to an actual channel by a ChannelResolver)request
- the object to convert to a request messagerequestPostProcessor
- the callback to modify the request message
protected MessageChannel resolveChannelName(java.lang.String channelName)
MessageChannel
,
via this template's ChannelResolver
if available.
channelName
- the name of the channel
MessageChannel
java.lang.IllegalStateException
- if this template does not have a ChannelResolver
ChannelResolutionException
- if the channel name cannot be resolvedsetChannelResolver(org.springframework.integration.support.channel.ChannelResolver)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |