类 JmsMessagingTemplate
- java.lang.Object
- org.springframework.messaging.core.AbstractMessageSendingTemplate<D>
- org.springframework.messaging.core.AbstractMessageReceivingTemplate<D>
- org.springframework.messaging.core.AbstractMessagingTemplate<Destination>
- org.springframework.jms.core.JmsMessagingTemplate
- 所有已实现的接口:
InitializingBean
,JmsMessageOperations
,MessageReceivingOperations<Destination>
,MessageRequestReplyOperations<Destination>
,MessageSendingOperations<Destination>
public class JmsMessagingTemplate extends AbstractMessagingTemplate<Destination> implements JmsMessageOperations, InitializingBean
An implementation ofJmsMessageOperations
.- 从以下版本开始:
- 4.1
- 作者:
- Stephane Nicoll, Juergen Hoeller
字段概要
从类继承的字段 org.springframework.messaging.core.AbstractMessageSendingTemplate
CONVERSION_HINT_HEADER, logger
构造器概要
构造器 构造器 说明 JmsMessagingTemplate()
Constructor for use with bean properties.JmsMessagingTemplate(ConnectionFactory connectionFactory)
Create aJmsMessagingTemplate
instance with the JMSConnectionFactory
to use, implicitly building aJmsTemplate
based on it.JmsMessagingTemplate(JmsTemplate jmsTemplate)
Create aJmsMessagingTemplate
instance with theJmsTemplate
to use.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.void
convertAndSend(Object payload)
Convert the given Object to serialized form, possibly using aMessageConverter
, wrap it as a message and send it to a default destination.void
convertAndSend(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.void
convertAndSend(String destinationName, Object payload)
Convert the given Object to serialized form, possibly using aMessageConverter
, 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 aMessageConverter
, 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, 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.void
convertAndSend(String destinationName, 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.protected MessagingException
convertJmsException(JmsException ex)
protected Message<?>
convertJmsMessage(Message message)
<T> T
convertSendAndReceive(Object request, Class<T> targetClass)
Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
to a default destination, receive the reply and convert its body of the specified target class.<T> T
convertSendAndReceive(Object request, Class<T> targetClass, MessagePostProcessor postProcessor)
Convert the given request Object to serialized form, possibly using aMessageConverter
, apply the given post processor and send the resultingMessage
to a default destination, receive the reply and convert its body of the given target class.<T> T
convertSendAndReceive(String destinationName, Object request, Class<T> targetClass)
Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
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, MessagePostProcessor requestPostProcessor)
Convert the given request Object to serialized form, possibly using aMessageConverter
, apply the given post processor and send the resultingMessage
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 aMessageConverter
, send it as aMessage
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, MessagePostProcessor postProcessor)
Convert the given request Object to serialized form, possibly using aMessageConverter
, wrap it as a message with the given headers, apply the given post processor and send the resultingMessage
to the specified destination, receive the reply and convert its body of the given target class.protected Message<?>
doReceive(String destinationName)
protected Message<?>
doReceive(Destination destination)
Actually receive a message from the given destination.protected void
doSend(String destinationName, Message<?> message)
protected void
doSend(Destination destination, Message<?> message)
protected Message<?>
doSendAndReceive(String destinationName, Message<?> requestMessage)
protected Message<?>
doSendAndReceive(Destination destination, Message<?> requestMessage)
ConnectionFactory
getConnectionFactory()
Return the ConnectionFactory that the underlyingJmsTemplate
uses.String
getDefaultDestinationName()
Return the configured default destination name.MessageConverter
getJmsMessageConverter()
JmsTemplate
getJmsTemplate()
Return the configuredJmsTemplate
.protected String
getRequiredDefaultDestinationName()
Message<?>
receive()
Receive a message from a default destination.Message<?>
receive(String destinationName)
Receive a message from the given destination.<T> T
receiveAndConvert(Class<T> targetClass)
Receive a message from a default destination and convert its payload to the specified target class.<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(String destinationName, Message<?> message)
Send a message to the given destination.void
send(Message<?> message)
Send a message to a default destination.Message<?>
sendAndReceive(String destinationName, Message<?> requestMessage)
Send a request message and receive the reply from the given destination.Message<?>
sendAndReceive(Message<?> requestMessage)
Send a request message and receive the reply from a default destination.void
setConnectionFactory(ConnectionFactory connectionFactory)
Set the ConnectionFactory to use for the underlyingJmsTemplate
.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 theJmsTemplate
to use.从类继承的方法 org.springframework.messaging.core.AbstractMessagingTemplate
convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive
从类继承的方法 org.springframework.messaging.core.AbstractMessageReceivingTemplate
doConvert, receive, receiveAndConvert
从类继承的方法 org.springframework.messaging.core.AbstractMessageSendingTemplate
convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, setDefaultDestination, setMessageConverter
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.messaging.core.MessageReceivingOperations
receive, receiveAndConvert
从接口继承的方法 org.springframework.messaging.core.MessageRequestReplyOperations
convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive
从接口继承的方法 org.springframework.messaging.core.MessageSendingOperations
convertAndSend, convertAndSend, convertAndSend, convertAndSend, send
构造器详细资料
JmsMessagingTemplate
public JmsMessagingTemplate()
Constructor for use with bean properties. RequiressetConnectionFactory(javax.jms.ConnectionFactory)
orsetJmsTemplate(org.springframework.jms.core.JmsTemplate)
to be called.
JmsMessagingTemplate
public JmsMessagingTemplate(ConnectionFactory connectionFactory)
Create aJmsMessagingTemplate
instance with the JMSConnectionFactory
to use, implicitly building aJmsTemplate
based on it.- 从以下版本开始:
- 4.1.2
JmsMessagingTemplate
public JmsMessagingTemplate(JmsTemplate jmsTemplate)
Create aJmsMessagingTemplate
instance with theJmsTemplate
to use.
方法详细资料
setConnectionFactory
public void setConnectionFactory(ConnectionFactory connectionFactory)
Set the ConnectionFactory to use for the underlyingJmsTemplate
.- 从以下版本开始:
- 4.1.2
getConnectionFactory
public ConnectionFactory getConnectionFactory()
Return the ConnectionFactory that the underlyingJmsTemplate
uses.- 从以下版本开始:
- 4.1.2
setJmsTemplate
public void setJmsTemplate(JmsTemplate jmsTemplate)
Set theJmsTemplate
to use.
getJmsTemplate
public JmsTemplate getJmsTemplate()
Return the configuredJmsTemplate
.
setJmsMessageConverter
public void setJmsMessageConverter(MessageConverter jmsMessageConverter)
Set theMessageConverter
to use to convert aMessage
from the messaging to and from aMessage
. By default, aMessagingMessageConverter
is defined using aSimpleMessageConverter
to convert the payload of the message.Consider configuring a
MessagingMessageConverter
with a differentpayload converter
for more advanced scenarios.
getJmsMessageConverter
public MessageConverter getJmsMessageConverter()
setDefaultDestinationName
public void setDefaultDestinationName(String defaultDestinationName)
Configure the default destination name 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.
getDefaultDestinationName
public String getDefaultDestinationName()
Return the configured default destination name.
afterPropertiesSet
public void afterPropertiesSet()
从接口复制的说明:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet
在接口中InitializingBean
send
public void send(Message<?> message)
从接口复制的说明:MessageSendingOperations
Send a message to a default destination.- 指定者:
send
在接口中MessageSendingOperations<Destination>
- 覆盖:
send
在类中AbstractMessageSendingTemplate<Destination>
- 参数:
message
- the message to send
convertAndSend
public void convertAndSend(Object payload) throws MessagingException
从接口复制的说明:MessageSendingOperations
Convert the given Object to serialized form, possibly using aMessageConverter
, wrap it as a message and send it to a default destination.- 指定者:
convertAndSend
在接口中MessageSendingOperations<Destination>
- 覆盖:
convertAndSend
在类中AbstractMessageSendingTemplate<Destination>
- 参数:
payload
- the Object to use as payload- 抛出:
MessagingException
convertAndSend
public void convertAndSend(Object payload, MessagePostProcessor postProcessor) throws MessagingException
从接口复制的说明:MessageSendingOperations
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.- 指定者:
convertAndSend
在接口中MessageSendingOperations<Destination>
- 覆盖:
convertAndSend
在类中AbstractMessageSendingTemplate<Destination>
- 参数:
payload
- the Object to use as payloadpostProcessor
- the post processor to apply to the message- 抛出:
MessagingException
send
public void send(String destinationName, Message<?> message) throws MessagingException
从接口复制的说明:JmsMessageOperations
Send a message to the given destination.- 指定者:
send
在接口中JmsMessageOperations
- 参数:
destinationName
- the name of the target destinationmessage
- the message to send- 抛出:
MessagingException
convertAndSend
public void convertAndSend(String destinationName, Object payload) throws MessagingException
从接口复制的说明:JmsMessageOperations
Convert the given Object to serialized form, possibly using aMessageConverter
, wrap it as a message and send it to the given destination.- 指定者:
convertAndSend
在接口中JmsMessageOperations
- 参数:
destinationName
- the name of the target destinationpayload
- the Object to use as payload- 抛出:
MessagingException
convertAndSend
public void convertAndSend(String destinationName, Object payload, Map<String,Object> headers) throws MessagingException
从接口复制的说明:JmsMessageOperations
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.- 指定者:
convertAndSend
在接口中JmsMessageOperations
- 参数:
destinationName
- the name of the target destinationpayload
- the Object to use as payloadheaders
- headers for the message to send- 抛出:
MessagingException
convertAndSend
public void convertAndSend(String destinationName, Object payload, MessagePostProcessor postProcessor) throws MessagingException
从接口复制的说明:JmsMessageOperations
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.- 指定者:
convertAndSend
在接口中JmsMessageOperations
- 参数:
destinationName
- the name of the target destinationpayload
- the Object to use as payloadpostProcessor
- the post processor to apply to the message- 抛出:
MessagingException
convertAndSend
public void convertAndSend(String destinationName, Object payload, Map<String,Object> headers, MessagePostProcessor postProcessor) throws MessagingException
从接口复制的说明:JmsMessageOperations
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.- 指定者:
convertAndSend
在接口中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 message- 抛出:
MessagingException
receive
public Message<?> receive()
从接口复制的说明:MessageReceivingOperations
Receive a message from a default destination.- 指定者:
receive
在接口中MessageReceivingOperations<Destination>
- 覆盖:
receive
在类中AbstractMessageReceivingTemplate<Destination>
- 返回:
- the received message, possibly
null
if the message could not be received, for example due to a timeout
receiveAndConvert
public <T> T receiveAndConvert(Class<T> targetClass)
从接口复制的说明:MessageReceivingOperations
Receive a message from a default destination and convert its payload to the specified target class.- 指定者:
receiveAndConvert
在接口中MessageReceivingOperations<Destination>
- 覆盖:
receiveAndConvert
在类中AbstractMessageReceivingTemplate<Destination>
- 参数:
targetClass
- the target class to convert the payload to- 返回:
- the converted payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout
receive
public Message<?> receive(String destinationName) throws MessagingException
从接口复制的说明:JmsMessageOperations
Receive a message from the given destination.- 指定者:
receive
在接口中JmsMessageOperations
- 参数:
destinationName
- the name of the target destination- 返回:
- the received message, possibly
null
if the message could not be received, for example due to a timeout - 抛出:
MessagingException
receiveAndConvert
public <T> T receiveAndConvert(String destinationName, Class<T> targetClass) throws MessagingException
从接口复制的说明:JmsMessageOperations
Receive a message from the given destination and convert its payload to the specified target class.- 指定者:
receiveAndConvert
在接口中JmsMessageOperations
- 参数:
destinationName
- the name of the target destinationtargetClass
- the target class to convert the payload to- 返回:
- the converted payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout - 抛出:
MessagingException
sendAndReceive
public Message<?> sendAndReceive(Message<?> requestMessage)
从接口复制的说明:MessageRequestReplyOperations
Send a request message and receive the reply from a default destination.- 指定者:
sendAndReceive
在接口中MessageRequestReplyOperations<Destination>
- 覆盖:
sendAndReceive
在类中AbstractMessagingTemplate<Destination>
- 参数:
requestMessage
- the message to send- 返回:
- the reply, possibly
null
if the message could not be received, for example due to a timeout
sendAndReceive
public Message<?> sendAndReceive(String destinationName, Message<?> requestMessage) throws MessagingException
从接口复制的说明:JmsMessageOperations
Send a request message and receive the reply from the given destination.- 指定者:
sendAndReceive
在接口中JmsMessageOperations
- 参数:
destinationName
- the name of the target destinationrequestMessage
- the message to send- 返回:
- the reply, possibly
null
if the message could not be received, for example due to a timeout - 抛出:
MessagingException
convertSendAndReceive
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass) throws MessagingException
从接口复制的说明:JmsMessageOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
to the given destination, receive the reply and convert its body of the specified target class.- 指定者:
convertSendAndReceive
在接口中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 to- 返回:
- the payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout - 抛出:
MessagingException
convertSendAndReceive
public <T> T convertSendAndReceive(Object request, Class<T> targetClass)
从接口复制的说明:MessageRequestReplyOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
to a default destination, receive the reply and convert its body of the specified target class.- 指定者:
convertSendAndReceive
在接口中MessageRequestReplyOperations<Destination>
- 覆盖:
convertSendAndReceive
在类中AbstractMessagingTemplate<Destination>
- 参数:
request
- payload for the request message to sendtargetClass
- the target type to convert the payload of the reply to- 返回:
- the payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout
convertSendAndReceive
public <T> T convertSendAndReceive(String destinationName, Object request, Map<String,Object> headers, Class<T> targetClass) throws MessagingException
从接口复制的说明:JmsMessageOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
with the given headers, to the specified destination, receive the reply and convert its body of the specified target class.- 指定者:
convertSendAndReceive
在接口中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 to- 返回:
- the payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout - 抛出:
MessagingException
convertSendAndReceive
public <T> T convertSendAndReceive(Object request, Class<T> targetClass, MessagePostProcessor postProcessor)
从接口复制的说明:MessageRequestReplyOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, apply the given post processor and send the resultingMessage
to a default destination, receive the reply and convert its body of the given target class.- 指定者:
convertSendAndReceive
在接口中MessageRequestReplyOperations<Destination>
- 覆盖:
convertSendAndReceive
在类中AbstractMessagingTemplate<Destination>
- 参数:
request
- 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 message- 返回:
- the payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout
convertSendAndReceive
public <T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException
从接口复制的说明:JmsMessageOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, apply the given post processor and send the resultingMessage
to the given destination, receive the reply and convert its body of the given target class.- 指定者:
convertSendAndReceive
在接口中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 message- 返回:
- the payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout - 抛出:
MessagingException
convertSendAndReceive
public <T> T convertSendAndReceive(String destinationName, Object request, Map<String,Object> headers, Class<T> targetClass, MessagePostProcessor postProcessor)
从接口复制的说明:JmsMessageOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, wrap it as a message with the given headers, apply the given post processor and send the resultingMessage
to the specified destination, receive the reply and convert its body of the given target class.- 指定者:
convertSendAndReceive
在接口中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 message- 返回:
- the payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout
doSend
protected void doSend(Destination destination, Message<?> message)
doReceive
protected Message<?> doReceive(Destination destination)
从类复制的说明:AbstractMessageReceivingTemplate
Actually receive a message from the given destination.- 指定者:
doReceive
在类中AbstractMessageReceivingTemplate<Destination>
- 参数:
destination
- the target destination- 返回:
- the received message, possibly
null
if the message could not be received, for example due to a timeout
doSendAndReceive
protected Message<?> doSendAndReceive(Destination destination, Message<?> requestMessage)
doSendAndReceive
protected Message<?> doSendAndReceive(String destinationName, Message<?> requestMessage)
getRequiredDefaultDestinationName
protected String getRequiredDefaultDestinationName()
convertJmsMessage
protected Message<?> convertJmsMessage(Message message)
convertJmsException
protected MessagingException convertJmsException(JmsException ex)