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(Object payload) |
void |
convertAndSend(Object payload,
org.springframework.messaging.core.MessagePostProcessor postProcessor) |
void |
convertAndSend(String destinationName,
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(String destinationName,
Object payload,
Map<String,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(String destinationName,
Object payload,
Map<String,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(String destinationName,
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(Object request,
Class<T> targetClass) |
<T> T |
convertSendAndReceive(Object request,
Class<T> targetClass,
org.springframework.messaging.core.MessagePostProcessor postProcessor) |
<T> T |
convertSendAndReceive(String destinationName,
Object request,
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(String destinationName,
Object request,
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(String destinationName,
Object request,
Map<String,Object> headers,
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(String destinationName,
Object request,
Map<String,Object> headers,
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(String destinationName) |
protected void |
doSend(Destination destination,
org.springframework.messaging.Message<?> message) |
protected void |
doSend(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(String destinationName,
org.springframework.messaging.Message<?> requestMessage) |
ConnectionFactory |
getConnectionFactory()
Return the ConnectionFactory that the underlying
JmsTemplate uses. |
String |
getDefaultDestinationName()
Return the configured default destination name.
|
MessageConverter |
getJmsMessageConverter()
|
JmsTemplate |
getJmsTemplate()
Return the configured
JmsTemplate. |
protected String |
getRequiredDefaultDestinationName() |
org.springframework.messaging.Message<?> |
receive() |
org.springframework.messaging.Message<?> |
receive(String destinationName)
Receive a message from the given destination.
|
<T> T |
receiveAndConvert(Class<T> targetClass) |
<T> T |
receiveAndConvert(String destinationName,
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(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(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(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, sendAndReceivedoConvert, receive, receiveAndConvertconvertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, setDefaultDestination, setMessageConverterclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertAndSend, convertAndSend, convertAndSend, convertAndSend, sendpublic 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.
MessagingMessageConverterpublic MessageConverter getJmsMessageConverter()
public void setDefaultDestinationName(@Nullable
String defaultDestinationName)
AbstractMessageSendingTemplate.setDefaultDestination(Object)@Nullable public String getDefaultDestinationName()
public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic 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(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.MessagingExceptionpublic void convertAndSend(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.MessagingExceptionpublic void send(String destinationName, org.springframework.messaging.Message<?> message) throws org.springframework.messaging.MessagingException
JmsMessageOperationssend in interface JmsMessageOperationsdestinationName - the name of the target destinationmessage - the message to sendorg.springframework.messaging.MessagingExceptionpublic void convertAndSend(String destinationName, Object payload) throws org.springframework.messaging.MessagingException
JmsMessageOperationsMessageConverter,
wrap it as a message and send it to the given destination.convertAndSend in interface JmsMessageOperationsdestinationName - the name of the target destinationpayload - the Object to use as payloadorg.springframework.messaging.MessagingExceptionpublic void convertAndSend(String destinationName, Object payload, @Nullable Map<String,Object> headers) throws org.springframework.messaging.MessagingException
JmsMessageOperationsMessageConverter,
wrap it as a message with the given headers and send it to
the given destination.convertAndSend in interface JmsMessageOperationsdestinationName - the name of the target destinationpayload - the Object to use as payloadheaders - the headers for the message to sendorg.springframework.messaging.MessagingExceptionpublic void convertAndSend(String destinationName, Object payload, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
JmsMessageOperationsMessageConverter,
wrap it as a message, apply the given post processor, and send
the resulting message to the given destination.convertAndSend in interface JmsMessageOperationsdestinationName - the name of the target destinationpayload - the Object to use as payloadpostProcessor - the post processor to apply to the messageorg.springframework.messaging.MessagingExceptionpublic void convertAndSend(String destinationName, Object payload, @Nullable Map<String,Object> headers, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor) throws org.springframework.messaging.MessagingException
JmsMessageOperationsMessageConverter,
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 JmsMessageOperationsdestinationName - the name of the target destinationpayload - the Object to use as payloadheaders - the 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(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(String destinationName) throws org.springframework.messaging.MessagingException
JmsMessageOperationsreceive in interface JmsMessageOperationsdestinationName - 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(String destinationName, Class<T> targetClass) throws org.springframework.messaging.MessagingException
JmsMessageOperationsreceiveAndConvert in interface JmsMessageOperationsdestinationName - 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(String destinationName, org.springframework.messaging.Message<?> requestMessage) throws org.springframework.messaging.MessagingException
JmsMessageOperationssendAndReceive in interface JmsMessageOperationsdestinationName - 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(String destinationName, Object request, Class<T> targetClass) throws org.springframework.messaging.MessagingException
JmsMessageOperationsMessageConverter, send
it as a Message to the given destination, receive the reply and convert
its body of the specified target class.convertSendAndReceive in interface JmsMessageOperationsdestinationName - 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(Object request, 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(String destinationName, Object request, @Nullable Map<String,Object> headers, Class<T> targetClass) throws org.springframework.messaging.MessagingException
JmsMessageOperationsMessageConverter, 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 JmsMessageOperationsdestinationName - the name of the target destinationrequest - payload for the request message to sendheaders - the 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(Object request, 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(String destinationName, Object request, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor requestPostProcessor) throws org.springframework.messaging.MessagingException
JmsMessageOperationsMessageConverter,
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 JmsMessageOperationsdestinationName - 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(String destinationName, Object request, @Nullable Map<String,Object> headers, Class<T> targetClass, @Nullable org.springframework.messaging.core.MessagePostProcessor postProcessor)
JmsMessageOperationsMessageConverter,
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 JmsMessageOperationsdestinationName - 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(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(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(String destinationName, org.springframework.messaging.Message<?> requestMessage)
protected String getRequiredDefaultDestinationName()
@Nullable
protected org.springframework.messaging.Message<?> convertJmsMessage(@Nullable
Message message)
protected org.springframework.messaging.MessagingException convertJmsException(JmsException ex)