Class JmsMessageSender
java.lang.Object
org.springframework.jms.support.JmsAccessor
org.springframework.jms.support.destination.JmsDestinationAccessor
org.springframework.ws.transport.jms.JmsMessageSender
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
,WebServiceMessageSender
public class JmsMessageSender
extends org.springframework.jms.support.destination.JmsDestinationAccessor
implements WebServiceMessageSender
WebServiceMessageSender
implementation that uses JMS Message
s. Requires a JMS
ConnectionFactory
to operate.
This message sender supports URI's of the following format:
jms:destination[?param-name=param-value][¶m-name=param-value]*where the characters :, ?, and & stand for themselves. The destination represents the name of the
Queue
or Topic
that will be resolved by
the destination resolver
. Valid param-name include:
param-name Description deliveryMode Indicates whether the request message is persistent or not. This may be PERSISTENT or NON_PERSISTENT. See MessageProducer.setDeliveryMode(int)
messageType The message type. This may be BINARY_MESSAGE (the default) or TEXT_MESSAGE priority The JMS priority (0-9) associated with the request message. See MessageProducer.setPriority(int)
replyToName The name of the destination to which the response message must be sent, that will be resolved by the destination resolver
.timeToLive The lifetime, in milliseconds, of the request message. See MessageProducer.setTimeToLive(long)
If the replyToName is not set, a temporary queue
is used.
This class uses BytesMessage
messages by default, but can be configured to send TextMessage
messages
instead. Note that BytesMessages
are preferred, since TextMessages
do not support attachments
and character encodings reliably.
Some examples of JMS URIs are:
jms:SomeQueue
jms:SomeTopic?priority=3&deliveryMode=NON_PERSISTENT
jms:RequestQueue?replyToName=ResponseQueueName
jms:Queue?messageType=TEXT_MESSAGE
- Since:
- 1.5.0
- Author:
- Arjen Poutsma
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
Default timeout for receive operations: -1 indicates a blocking receive without timeout.static final String
Default encoding used to read fromn and write toTextMessage
messages.Fields inherited from class org.springframework.jms.support.destination.JmsDestinationAccessor
RECEIVE_TIMEOUT_INDEFINITE_WAIT, RECEIVE_TIMEOUT_NO_WAIT
Fields inherited from class org.springframework.jms.support.JmsAccessor
logger
-
Constructor Summary
ConstructorDescriptionCreate a newJmsMessageSender
JmsMessageSender
(jakarta.jms.ConnectionFactory connectionFactory) Create a newJmsMessageSender
, given a ConnectionFactory. -
Method Summary
Modifier and TypeMethodDescriptioncreateConnection
(URI uri) Create a newWebServiceConnection
to the specified URI.void
setPostProcessor
(org.springframework.jms.core.MessagePostProcessor postProcessor) Sets the optionalMessagePostProcessor
to further modify outgoing messages after the XML contents has been set.void
setReceiveTimeout
(long receiveTimeout) Set the timeout to use for receive calls.void
setTextMessageEncoding
(String textMessageEncoding) Sets the encoding used to read fromTextMessage
messages.boolean
Does thisWebServiceMessageSender
support the supplied URI?Methods inherited from class org.springframework.jms.support.destination.JmsDestinationAccessor
getDestinationResolver, isPubSubDomain, receiveFromConsumer, resolveDestinationName, setDestinationResolver, setPubSubDomain
Methods inherited from class org.springframework.jms.support.JmsAccessor
afterPropertiesSet, convertJmsAccessException, createConnection, createSession, getConnectionFactory, getSessionAcknowledgeMode, isClientAcknowledge, isSessionTransacted, obtainConnectionFactory, setConnectionFactory, setSessionAcknowledgeMode, setSessionAcknowledgeModeName, setSessionTransacted
-
Field Details
-
DEFAULT_RECEIVE_TIMEOUT
public static final long DEFAULT_RECEIVE_TIMEOUTDefault timeout for receive operations: -1 indicates a blocking receive without timeout.- See Also:
-
DEFAULT_TEXT_MESSAGE_ENCODING
Default encoding used to read fromn and write toTextMessage
messages.- See Also:
-
-
Constructor Details
-
JmsMessageSender
public JmsMessageSender()Create a newJmsMessageSender
Note: The ConnectionFactory has to be set before using the instance. This constructor can be used to prepare a JmsTemplate via a BeanFactory, typically setting the ConnectionFactory via
JmsAccessor.setConnectionFactory(ConnectionFactory)
.- See Also:
-
JmsAccessor.setConnectionFactory(ConnectionFactory)
-
JmsMessageSender
public JmsMessageSender(jakarta.jms.ConnectionFactory connectionFactory) Create a newJmsMessageSender
, given a ConnectionFactory.- Parameters:
connectionFactory
- the ConnectionFactory to obtain Connections from
-
-
Method Details
-
setReceiveTimeout
public void setReceiveTimeout(long receiveTimeout) Set the timeout to use for receive calls. The default is -1, which means no timeout.- See Also:
-
MessageConsumer.receive(long)
-
setTextMessageEncoding
Sets the encoding used to read fromTextMessage
messages. Defaults toUTF-8
. -
setPostProcessor
public void setPostProcessor(org.springframework.jms.core.MessagePostProcessor postProcessor) Sets the optionalMessagePostProcessor
to further modify outgoing messages after the XML contents has been set. -
createConnection
Description copied from interface:WebServiceMessageSender
Create a newWebServiceConnection
to the specified URI.- Specified by:
createConnection
in interfaceWebServiceMessageSender
- Parameters:
uri
- the URI to open a connection to- Returns:
- the new connection
- Throws:
IOException
- in case of I/O errors
-
supports
Description copied from interface:WebServiceMessageSender
Does thisWebServiceMessageSender
support the supplied URI?- Specified by:
supports
in interfaceWebServiceMessageSender
- Parameters:
uri
- the URI to be checked- Returns:
true
if thisWebServiceMessageSender
supports the supplied URI
-