public class JmsMessageSender extends 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
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_RECEIVE_TIMEOUT
Default timeout for receive operations: -1 indicates a blocking receive without timeout.
|
static String |
DEFAULT_TEXT_MESSAGE_ENCODING
Default encoding used to read fromn and write to
TextMessage messages. |
logger
Constructor and Description |
---|
JmsMessageSender()
Create a new
JmsMessageSender |
JmsMessageSender(ConnectionFactory connectionFactory)
Create a new
JmsMessageSender , given a ConnectionFactory. |
Modifier and Type | Method and Description |
---|---|
WebServiceConnection |
createConnection(URI uri)
Create a new
WebServiceConnection to the specified URI. |
void |
setPostProcessor(MessagePostProcessor postProcessor)
Sets the optional
MessagePostProcessor 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 from
TextMessage messages. |
boolean |
supports(URI uri)
Does this
WebServiceMessageSender support the supplied URI? |
getDestinationResolver, isPubSubDomain, resolveDestinationName, setDestinationResolver, setPubSubDomain
afterPropertiesSet, convertJmsAccessException, createConnection, createSession, getConnectionFactory, getSessionAcknowledgeMode, isClientAcknowledge, isSessionTransacted, setConnectionFactory, setSessionAcknowledgeMode, setSessionAcknowledgeModeName, setSessionTransacted
public static final long DEFAULT_RECEIVE_TIMEOUT
public static final String DEFAULT_TEXT_MESSAGE_ENCODING
TextMessage
messages.public JmsMessageSender()
JmsMessageSender
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)
.
public JmsMessageSender(ConnectionFactory connectionFactory)
JmsMessageSender
, given a ConnectionFactory.connectionFactory
- the ConnectionFactory to obtain Connections frompublic void setReceiveTimeout(long receiveTimeout)
MessageConsumer.receive(long)
public void setTextMessageEncoding(String textMessageEncoding)
TextMessage
messages. Defaults to UTF-8
.public void setPostProcessor(MessagePostProcessor postProcessor)
MessagePostProcessor
to further modify outgoing messages after the XML contents has
been set.public WebServiceConnection createConnection(URI uri) throws IOException
WebServiceMessageSender
WebServiceConnection
to the specified URI.createConnection
in interface WebServiceMessageSender
uri
- the URI to open a connection toIOException
- in case of I/O errorspublic boolean supports(URI uri)
WebServiceMessageSender
WebServiceMessageSender
support the supplied URI?supports
in interface WebServiceMessageSender
uri
- the URI to be checkedtrue
if this WebServiceMessageSender
supports the supplied URI