public class JmsMessagingTemplate extends org.springframework.messaging.core.AbstractMessagingTemplate<Destination> implements JmsMessageOperations, org.springframework.beans.factory.InitializingBean
JmsMessageOperations
.Constructor and Description |
---|
JmsMessagingTemplate()
Constructor for use with bean properties.
|
JmsMessagingTemplate(ConnectionFactory connectionFactory)
Create a
JmsMessagingTemplate instance with the JMS ConnectionFactory
to use, implicitly building a JmsTemplate based on it. |
JmsMessagingTemplate(JmsTemplate jmsTemplate)
Create a
JmsMessagingTemplate instance with the JmsTemplate to use. |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
convertAndSend(java.lang.Object payload) |
void |
convertAndSend(java.lang.Object payload,
org.springframework.messaging.core.MessagePostProcessor postProcessor) |
void |
convertAndSend(java.lang.String destinationName,
java.lang.Object payload)
Convert the given Object to serialized form, possibly using a
MessageConverter ,
wrap it as a message and send it to the given destination. |
void |
convertAndSend(java.lang.String destinationName,
java.lang.Object payload,
java.util.Map<java.lang.String,java.lang.Object> headers)
Convert the given Object to serialized form, possibly using a
MessageConverter ,
wrap it as a message with the given headers and send it to
the given destination. |
void |
convertAndSend(java.lang.String destinationName,
java.lang.Object payload,
java.util.Map<java.lang.String,java.lang.Object> headers,
org.springframework.messaging.core.MessagePostProcessor postProcessor)
Convert the given 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 given destination. |
void |
convertAndSend(java.lang.String destinationName,
java.lang.Object payload,
org.springframework.messaging.core.MessagePostProcessor postProcessor)
Convert the given 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 given destination. |
protected org.springframework.messaging.MessagingException |
convertJmsException(JmsException ex) |
protected org.springframework.messaging.Message<?> |
convertJmsMessage(Message message) |
<T> T |
convertSendAndReceive(java.lang.Object request,
java.lang.Class<T> targetClass) |
<T> T |
convertSendAndReceive(java.lang.Object request,
java.lang.Class<T> targetClass,
org.springframework.messaging.core.MessagePostProcessor postProcessor) |
<T> T |
convertSendAndReceive(java.lang.String destinationName,
java.lang.Object request,
java.lang.Class<T> targetClass)
Convert the given request Object to serialized form, possibly using a
MessageConverter , send
it as a Message to the given destination, receive the reply and convert
its body of the specified target class. |
<T> T |
convertSendAndReceive(java.lang.String destinationName,
java.lang.Object request,
java.lang.Class<T> targetClass,
org.springframework.messaging.core.MessagePostProcessor requestPostProcessor)
Convert the given request Object to serialized form, possibly using a
MessageConverter ,
apply the given post processor and send the resulting Message to the
given destination, receive the reply and convert its body of the given
target class. |
<T> T |
convertSendAndReceive(java.lang.String destinationName,
java.lang.Object request,
java.util.Map<java.lang.String,java.lang.Object> headers,
java.lang.Class<T> targetClass)
Convert the given request Object to serialized form, possibly using a
MessageConverter , send
it as a Message with the given headers, to the specified destination,
receive the reply and convert its body of the specified target class. |
<T> T |
convertSendAndReceive(java.lang.String destinationName,
java.lang.Object request,
java.util.Map<java.lang.String,java.lang.Object> headers,
java.lang.Class<T> targetClass,
org.springframework.messaging.core.MessagePostProcessor postProcessor)
Convert the given request 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 specified destination, receive
the reply and convert its body of the given target class. |
protected org.springframework.messaging.Message<?> |
doReceive(Destination destination) |
protected org.springframework.messaging.Message<?> |
doReceive(java.lang.String destinationName) |
protected void |
doSend(Destination destination,
org.springframework.messaging.Message<?> message) |
protected void |
doSend(java.lang.String destinationName,
org.springframework.messaging.Message<?> message) |
protected org.springframework.messaging.Message<?> |
doSendAndReceive(Destination destination,
org.springframework.messaging.Message<?> requestMessage) |
protected org.springframework.messaging.Message<?> |
doSendAndReceive(java.lang.String destinationName,
org.springframework.messaging.Message<?> requestMessage) |
ConnectionFactory |
getConnectionFactory()
Return the ConnectionFactory that the underlying
JmsTemplate uses. |
java.lang.String |
getDefaultDestinationName()
Return the configured default destination name.
|
MessageConverter |
getJmsMessageConverter()
|
JmsTemplate |
getJmsTemplate()
Return the configured
JmsTemplate . |
protected java.lang.String |
getRequiredDefaultDestinationName() |
org.springframework.messaging.Message<?> |
receive() |
org.springframework.messaging.Message<?> |
receive(java.lang.String destinationName)
Receive a message from the given destination.
|
<T> T |
receiveAndConvert(java.lang.Class<T> targetClass) |
<T> T |
receiveAndConvert(java.lang.String destinationName,
java.lang.Class<T> targetClass)
Receive a message from the given destination and convert its payload to the
specified target class.
|
void |
send(org.springframework.messaging.Message<?> message) |
void |
send(java.lang.String destinationName,
org.springframework.messaging.Message<?> message)
Send a message to the given destination.
|
org.springframework.messaging.Message<?> |
sendAndReceive(org.springframework.messaging.Message<?> requestMessage) |
org.springframework.messaging.Message<?> |
sendAndReceive(java.lang.String destinationName,
org.springframework.messaging.Message<?> requestMessage)
Send a request message and receive the reply from the given destination.
|
void |
setConnectionFactory(ConnectionFactory connectionFactory)
Set the ConnectionFactory to use for the underlying
JmsTemplate . |
void |
setDefaultDestinationName(java.lang.String defaultDestinationName)
Configure the default destination name to use in send methods that don't have
a destination argument.
|
void |
setJmsMessageConverter(MessageConverter jmsMessageConverter)
|
void |
setJmsTemplate(JmsTemplate jmsTemplate)
Set the
JmsTemplate to use. |
convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive
doConvert, receive, receiveAndConvert
convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, setDefaultDestination, setMessageConverter
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convertAndSend, convertAndSend, convertAndSend, convertAndSend, send
public JmsMessagingTemplate()
setConnectionFactory(javax.jms.ConnectionFactory)
or setJmsTemplate(org.springframework.jms.core.JmsTemplate)
to be called.public JmsMessagingTemplate(ConnectionFactory connectionFactory)
JmsMessagingTemplate
instance with the JMS ConnectionFactory
to use, implicitly building a JmsTemplate
based on it.public JmsMessagingTemplate(JmsTemplate jmsTemplate)
JmsMessagingTemplate
instance with the JmsTemplate
to use.public void setConnectionFactory(ConnectionFactory connectionFactory)
JmsTemplate
.@Nullable public ConnectionFactory getConnectionFactory()
JmsTemplate
uses.public void setJmsTemplate(@Nullable JmsTemplate jmsTemplate)
JmsTemplate
to use.@Nullable public JmsTemplate getJmsTemplate()
JmsTemplate
.public void setJmsMessageConverter(MessageConverter jmsMessageConverter)
MessageConverter
to use to convert a Message
from
the messaging to and from a Message
. By default, a
MessagingMessageConverter
is defined using a SimpleMessageConverter
to convert the payload of the message.
Consider configuring a MessagingMessageConverter
with a different
payload converter
for more advanced scenarios.
MessagingMessageConverter
public MessageConverter getJmsMessageConverter()
public void setDefaultDestinationName(@Nullable java.lang.String defaultDestinationName)
AbstractMessageSendingTemplate.setDefaultDestination(Object)
@Nullable public java.lang.String getDefaultDestinationName()
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public void send(org.springframework.messaging.Message<?> message)
send
in interface org.springframework.messaging.core.MessageSendingOperations<Destination>
send
in class org.springframework.messaging.core.AbstractMessageSendingTemplate<Destination>
public void convertAndSend(java.lang.Object payload) throws org.springframework.messaging.MessagingException
convertAndSend
in interface org.springframework.messaging.core.MessageSendingOperations<Destination>
convertAndSend
in class org.springframework.messaging.core.AbstractMessageSendingTemplate<Destination>
org.springframework.messaging.MessagingException
public void convertAndSend(java.lang.Object payload, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
convertAndSend
in interface org.springframework.messaging.core.MessageSendingOperations<Destination>
convertAndSend
in class org.springframework.messaging.core.AbstractMessageSendingTemplate<Destination>
org.springframework.messaging.MessagingException
public void send(java.lang.String destinationName, org.springframework.messaging.Message<?> message) throws org.springframework.messaging.MessagingException
JmsMessageOperations
send
in interface JmsMessageOperations
destinationName
- the name of the target destinationmessage
- the message to sendorg.springframework.messaging.MessagingException
public void convertAndSend(java.lang.String destinationName, java.lang.Object payload) throws org.springframework.messaging.MessagingException
JmsMessageOperations
MessageConverter
,
wrap it as a message and send it to the given destination.convertAndSend
in interface JmsMessageOperations
destinationName
- the name of the target destinationpayload
- the Object to use as payloadorg.springframework.messaging.MessagingException
public void convertAndSend(java.lang.String destinationName, java.lang.Object payload, @Nullable java.util.Map<java.lang.String,java.lang.Object> headers) throws org.springframework.messaging.MessagingException
JmsMessageOperations
MessageConverter
,
wrap it as a message with the given headers and send it to
the given destination.convertAndSend
in interface JmsMessageOperations
destinationName
- the name of the target destinationpayload
- the Object to use as payloadheaders
- headers for the message to sendorg.springframework.messaging.MessagingException
public void convertAndSend(java.lang.String destinationName, java.lang.Object payload, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
JmsMessageOperations
MessageConverter
,
wrap it as a message, apply the given post processor, and send
the resulting message to the given destination.convertAndSend
in interface JmsMessageOperations
destinationName
- the name of the target destinationpayload
- the Object to use as payloadpostProcessor
- the post processor to apply to the messageorg.springframework.messaging.MessagingException
public void convertAndSend(java.lang.String destinationName, java.lang.Object payload, @Nullable java.util.Map<java.lang.String,java.lang.Object> headers, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
JmsMessageOperations
MessageConverter
,
wrap it as a message with the given headers, apply the given post processor,
and send the resulting message to the given destination.convertAndSend
in interface JmsMessageOperations
destinationName
- the name of the target destinationpayload
- the Object to use as payloadheaders
- headers for the message to sendpostProcessor
- the post processor to apply to the messageorg.springframework.messaging.MessagingException
@Nullable public org.springframework.messaging.Message<?> receive()
receive
in interface org.springframework.messaging.core.MessageReceivingOperations<Destination>
receive
in class org.springframework.messaging.core.AbstractMessageReceivingTemplate<Destination>
@Nullable public <T> T receiveAndConvert(java.lang.Class<T> targetClass)
receiveAndConvert
in interface org.springframework.messaging.core.MessageReceivingOperations<Destination>
receiveAndConvert
in class org.springframework.messaging.core.AbstractMessageReceivingTemplate<Destination>
@Nullable public org.springframework.messaging.Message<?> receive(java.lang.String destinationName) throws org.springframework.messaging.MessagingException
JmsMessageOperations
receive
in interface JmsMessageOperations
destinationName
- the name of the target destinationnull
if the message could not
be received, for example due to a timeoutorg.springframework.messaging.MessagingException
@Nullable public <T> T receiveAndConvert(java.lang.String destinationName, java.lang.Class<T> targetClass) throws org.springframework.messaging.MessagingException
JmsMessageOperations
receiveAndConvert
in interface JmsMessageOperations
destinationName
- the name of the target destinationtargetClass
- the target class to convert the payload tonull
if
the message could not be received, for example due to a timeoutorg.springframework.messaging.MessagingException
@Nullable public org.springframework.messaging.Message<?> sendAndReceive(org.springframework.messaging.Message<?> requestMessage)
sendAndReceive
in interface org.springframework.messaging.core.MessageRequestReplyOperations<Destination>
sendAndReceive
in class org.springframework.messaging.core.AbstractMessagingTemplate<Destination>
@Nullable public org.springframework.messaging.Message<?> sendAndReceive(java.lang.String destinationName, org.springframework.messaging.Message<?> requestMessage) throws org.springframework.messaging.MessagingException
JmsMessageOperations
sendAndReceive
in interface JmsMessageOperations
destinationName
- the name of the target destinationrequestMessage
- the message to sendnull
if the message could not be received,
for example due to a timeoutorg.springframework.messaging.MessagingException
@Nullable public <T> T convertSendAndReceive(java.lang.String destinationName, java.lang.Object request, java.lang.Class<T> targetClass) throws org.springframework.messaging.MessagingException
JmsMessageOperations
MessageConverter
, send
it as a Message
to the given destination, receive the reply and convert
its body of the specified target class.convertSendAndReceive
in interface JmsMessageOperations
destinationName
- the name of the target destinationrequest
- payload for the request message to sendtargetClass
- the target type to convert the payload of the reply tonull
if the message
could not be received, for example due to a timeoutorg.springframework.messaging.MessagingException
@Nullable public <T> T convertSendAndReceive(java.lang.Object request, java.lang.Class<T> targetClass)
convertSendAndReceive
in interface org.springframework.messaging.core.MessageRequestReplyOperations<Destination>
convertSendAndReceive
in class org.springframework.messaging.core.AbstractMessagingTemplate<Destination>
@Nullable public <T> T convertSendAndReceive(java.lang.String destinationName, java.lang.Object request, @Nullable java.util.Map<java.lang.String,java.lang.Object> headers, java.lang.Class<T> targetClass) throws org.springframework.messaging.MessagingException
JmsMessageOperations
MessageConverter
, send
it as a Message
with the given headers, to the specified destination,
receive the reply and convert its body of the specified target class.convertSendAndReceive
in interface JmsMessageOperations
destinationName
- the name of the target destinationrequest
- payload for the request message to sendheaders
- headers for the request message to sendtargetClass
- the target type to convert the payload of the reply tonull
if the message
could not be received, for example due to a timeoutorg.springframework.messaging.MessagingException
@Nullable public <T> T convertSendAndReceive(java.lang.Object request, java.lang.Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor)
convertSendAndReceive
in interface org.springframework.messaging.core.MessageRequestReplyOperations<Destination>
convertSendAndReceive
in class org.springframework.messaging.core.AbstractMessagingTemplate<Destination>
@Nullable public <T> T convertSendAndReceive(java.lang.String destinationName, java.lang.Object request, java.lang.Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor requestPostProcessor) throws org.springframework.messaging.MessagingException
JmsMessageOperations
MessageConverter
,
apply the given post processor and send the resulting Message
to the
given destination, receive the reply and convert its body of the given
target class.convertSendAndReceive
in interface JmsMessageOperations
destinationName
- the name of the target destinationrequest
- payload for the request message to sendtargetClass
- the target type to convert the payload of the reply torequestPostProcessor
- post process to apply to the request messagenull
if the message
could not be received, for example due to a timeoutorg.springframework.messaging.MessagingException
@Nullable public <T> T convertSendAndReceive(java.lang.String destinationName, java.lang.Object request, @Nullable java.util.Map<java.lang.String,java.lang.Object> headers, java.lang.Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor)
JmsMessageOperations
MessageConverter
,
wrap it as a message with the given headers, apply the given post processor
and send the resulting Message
to the specified destination, receive
the reply and convert its body of the given target class.convertSendAndReceive
in interface JmsMessageOperations
destinationName
- the name of the target destinationrequest
- payload for the request message to sendtargetClass
- the target type to convert the payload of the reply topostProcessor
- post process to apply to the request messagenull
if the message
could not be received, for example due to a timeoutprotected void doSend(Destination destination, org.springframework.messaging.Message<?> message)
doSend
in class org.springframework.messaging.core.AbstractMessageSendingTemplate<Destination>
protected void doSend(java.lang.String destinationName, org.springframework.messaging.Message<?> message)
@Nullable protected org.springframework.messaging.Message<?> doReceive(Destination destination)
doReceive
in class org.springframework.messaging.core.AbstractMessageReceivingTemplate<Destination>
@Nullable protected org.springframework.messaging.Message<?> doReceive(java.lang.String destinationName)
@Nullable protected org.springframework.messaging.Message<?> doSendAndReceive(Destination destination, org.springframework.messaging.Message<?> requestMessage)
doSendAndReceive
in class org.springframework.messaging.core.AbstractMessagingTemplate<Destination>
@Nullable protected org.springframework.messaging.Message<?> doSendAndReceive(java.lang.String destinationName, org.springframework.messaging.Message<?> requestMessage)
protected java.lang.String getRequiredDefaultDestinationName()
@Nullable protected org.springframework.messaging.Message<?> convertJmsMessage(@Nullable Message message)
protected org.springframework.messaging.MessagingException convertJmsException(JmsException ex)