public interface JmsOperations
Implemented by JmsTemplate
. Not often used but a useful option
to enhance testability, as it can easily be mocked or stubbed.
Provides JmsTemplate's
send(..)
and
receive(..)
methods that mirror various JMS API methods.
See the JMS specification and javadocs for details on those methods.
Provides also basic request reply operation using a temporary queue to collect the reply.
JmsTemplate
,
Destination
,
Session
,
MessageProducer
,
MessageConsumer
Modifier and Type | Method and Description |
---|---|
<T> T |
browse(BrowserCallback<T> action)
Browse messages in the default JMS queue.
|
<T> T |
browse(Queue queue,
BrowserCallback<T> action)
Browse messages in a JMS queue.
|
<T> T |
browse(String queueName,
BrowserCallback<T> action)
Browse messages in a JMS queue.
|
<T> T |
browseSelected(Queue queue,
String messageSelector,
BrowserCallback<T> action)
Browse selected messages in a JMS queue.
|
<T> T |
browseSelected(String messageSelector,
BrowserCallback<T> action)
Browse selected messages in a JMS queue.
|
<T> T |
browseSelected(String queueName,
String messageSelector,
BrowserCallback<T> action)
Browse selected messages in a JMS queue.
|
void |
convertAndSend(Destination destination,
Object message)
Send the given object to the specified destination, converting the object
to a JMS message with a configured MessageConverter.
|
void |
convertAndSend(Destination destination,
Object message,
MessagePostProcessor postProcessor)
Send the given object to the specified destination, converting the object
to a JMS message with a configured MessageConverter.
|
void |
convertAndSend(Object message)
Send the given object to the default destination, converting the object
to a JMS message with a configured MessageConverter.
|
void |
convertAndSend(Object message,
MessagePostProcessor postProcessor)
Send the given object to the default destination, converting the object
to a JMS message with a configured MessageConverter.
|
void |
convertAndSend(String destinationName,
Object message)
Send the given object to the specified destination, converting the object
to a JMS message with a configured MessageConverter.
|
void |
convertAndSend(String destinationName,
Object message,
MessagePostProcessor postProcessor)
Send the given object to the specified destination, converting the object
to a JMS message with a configured MessageConverter.
|
<T> T |
execute(Destination destination,
ProducerCallback<T> action)
Send messages to a JMS destination.
|
<T> T |
execute(ProducerCallback<T> action)
Send messages to the default JMS destination (or one specified
for each send operation).
|
<T> T |
execute(SessionCallback<T> action)
Execute the action specified by the given action object within a JMS Session.
|
<T> T |
execute(String destinationName,
ProducerCallback<T> action)
Send messages to a JMS destination.
|
Message |
receive()
Receive a message synchronously from the default destination, but only
wait up to a specified time for delivery.
|
Message |
receive(Destination destination)
Receive a message synchronously from the specified destination, but only
wait up to a specified time for delivery.
|
Message |
receive(String destinationName)
Receive a message synchronously from the specified destination, but only
wait up to a specified time for delivery.
|
Object |
receiveAndConvert()
Receive a message synchronously from the default destination, but only
wait up to a specified time for delivery.
|
Object |
receiveAndConvert(Destination destination)
Receive a message synchronously from the specified destination, but only
wait up to a specified time for delivery.
|
Object |
receiveAndConvert(String destinationName)
Receive a message synchronously from the specified destination, but only
wait up to a specified time for delivery.
|
Message |
receiveSelected(Destination destination,
String messageSelector)
Receive a message synchronously from the specified destination, but only
wait up to a specified time for delivery.
|
Message |
receiveSelected(String messageSelector)
Receive a message synchronously from the default destination, but only
wait up to a specified time for delivery.
|
Message |
receiveSelected(String destinationName,
String messageSelector)
Receive a message synchronously from the specified destination, but only
wait up to a specified time for delivery.
|
Object |
receiveSelectedAndConvert(Destination destination,
String messageSelector)
Receive a message synchronously from the specified destination, but only
wait up to a specified time for delivery.
|
Object |
receiveSelectedAndConvert(String messageSelector)
Receive a message synchronously from the default destination, but only
wait up to a specified time for delivery.
|
Object |
receiveSelectedAndConvert(String destinationName,
String messageSelector)
Receive a message synchronously from the specified destination, but only
wait up to a specified time for delivery.
|
void |
send(Destination destination,
MessageCreator messageCreator)
Send a message to the specified destination.
|
void |
send(MessageCreator messageCreator)
Send a message to the default destination.
|
void |
send(String destinationName,
MessageCreator messageCreator)
Send a message to the specified destination.
|
Message |
sendAndReceive(Destination destination,
MessageCreator messageCreator)
Send a message and receive the reply from the specified destination.
|
Message |
sendAndReceive(MessageCreator messageCreator)
Send a request message and receive the reply from a default destination.
|
Message |
sendAndReceive(String destinationName,
MessageCreator messageCreator)
Send a message and receive the reply from the specified destination.
|
@Nullable <T> T execute(SessionCallback<T> action) throws JmsException
action
- callback object that exposes the sessionJmsException
- if there is any problem@Nullable <T> T execute(ProducerCallback<T> action) throws JmsException
action
- callback object that exposes the session/producer pairJmsException
- checked JMSException converted to unchecked@Nullable <T> T execute(Destination destination, ProducerCallback<T> action) throws JmsException
destination
- the destination to send messages toaction
- callback object that exposes the session/producer pairJmsException
- checked JMSException converted to unchecked@Nullable <T> T execute(String destinationName, ProducerCallback<T> action) throws JmsException
destinationName
- the name of the destination to send messages to
(to be resolved to an actual destination by a DestinationResolver)action
- callback object that exposes the session/producer pairJmsException
- checked JMSException converted to uncheckedvoid send(MessageCreator messageCreator) throws JmsException
This will only work with a default destination specified!
messageCreator
- callback to create a messageJmsException
- checked JMSException converted to uncheckedvoid send(Destination destination, MessageCreator messageCreator) throws JmsException
destination
- the destination to send this message tomessageCreator
- callback to create a messageJmsException
- checked JMSException converted to uncheckedvoid send(String destinationName, MessageCreator messageCreator) throws JmsException
destinationName
- the name of the destination to send this message to
(to be resolved to an actual destination by a DestinationResolver)messageCreator
- callback to create a messageJmsException
- checked JMSException converted to uncheckedvoid convertAndSend(Object message) throws JmsException
This will only work with a default destination specified!
message
- the object to convert to a messageJmsException
- converted checked JMSException to uncheckedvoid convertAndSend(Destination destination, Object message) throws JmsException
destination
- the destination to send this message tomessage
- the object to convert to a messageJmsException
- converted checked JMSException to uncheckedvoid convertAndSend(String destinationName, Object message) throws JmsException
destinationName
- the name of the destination to send this message to
(to be resolved to an actual destination by a DestinationResolver)message
- the object to convert to a messageJmsException
- checked JMSException converted to uncheckedvoid convertAndSend(Object message, MessagePostProcessor postProcessor) throws JmsException
This will only work with a default destination specified!
message
- the object to convert to a messagepostProcessor
- the callback to modify the messageJmsException
- checked JMSException converted to uncheckedvoid convertAndSend(Destination destination, Object message, MessagePostProcessor postProcessor) throws JmsException
destination
- the destination to send this message tomessage
- the object to convert to a messagepostProcessor
- the callback to modify the messageJmsException
- checked JMSException converted to uncheckedvoid convertAndSend(String destinationName, Object message, MessagePostProcessor postProcessor) throws JmsException
destinationName
- the name of the destination to send this message to
(to be resolved to an actual destination by a DestinationResolver)message
- the object to convert to a message.postProcessor
- the callback to modify the messageJmsException
- checked JMSException converted to unchecked@Nullable Message receive() throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
This will only work with a default destination specified!
null
if the timeout expiresJmsException
- checked JMSException converted to unchecked@Nullable Message receive(Destination destination) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
destination
- the destination to receive a message fromnull
if the timeout expiresJmsException
- checked JMSException converted to unchecked@Nullable Message receive(String destinationName) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
destinationName
- the name of the destination to send this message to
(to be resolved to an actual destination by a DestinationResolver)null
if the timeout expiresJmsException
- checked JMSException converted to unchecked@Nullable Message receiveSelected(String messageSelector) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
This will only work with a default destination specified!
messageSelector
- the JMS message selector expression (or null
if none).
See the JMS specification for a detailed definition of selector expressions.null
if the timeout expiresJmsException
- checked JMSException converted to unchecked@Nullable Message receiveSelected(Destination destination, String messageSelector) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
destination
- the destination to receive a message frommessageSelector
- the JMS message selector expression (or null
if none).
See the JMS specification for a detailed definition of selector expressions.null
if the timeout expiresJmsException
- checked JMSException converted to unchecked@Nullable Message receiveSelected(String destinationName, String messageSelector) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
destinationName
- the name of the destination to send this message to
(to be resolved to an actual destination by a DestinationResolver)messageSelector
- the JMS message selector expression (or null
if none).
See the JMS specification for a detailed definition of selector expressions.null
if the timeout expiresJmsException
- checked JMSException converted to unchecked@Nullable Object receiveAndConvert() throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
This will only work with a default destination specified!
null
if the timeout expires.JmsException
- checked JMSException converted to unchecked@Nullable Object receiveAndConvert(Destination destination) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
destination
- the destination to receive a message fromnull
if the timeout expires.JmsException
- checked JMSException converted to unchecked@Nullable Object receiveAndConvert(String destinationName) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
destinationName
- the name of the destination to send this message to
(to be resolved to an actual destination by a DestinationResolver)null
if the timeout expires.JmsException
- checked JMSException converted to unchecked@Nullable Object receiveSelectedAndConvert(String messageSelector) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
This will only work with a default destination specified!
messageSelector
- the JMS message selector expression (or null
if none).
See the JMS specification for a detailed definition of selector expressions.null
if the timeout expires.JmsException
- checked JMSException converted to unchecked@Nullable Object receiveSelectedAndConvert(Destination destination, String messageSelector) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
destination
- the destination to receive a message frommessageSelector
- the JMS message selector expression (or null
if none).
See the JMS specification for a detailed definition of selector expressions.null
if the timeout expires.JmsException
- checked JMSException converted to unchecked@Nullable Object receiveSelectedAndConvert(String destinationName, String messageSelector) throws JmsException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
destinationName
- the name of the destination to send this message to
(to be resolved to an actual destination by a DestinationResolver)messageSelector
- the JMS message selector expression (or null
if none).
See the JMS specification for a detailed definition of selector expressions.null
if the timeout expires.JmsException
- checked JMSException converted to unchecked@Nullable Message sendAndReceive(MessageCreator messageCreator) throws JmsException
MessageCreator
callback creates the message given a Session. A temporary
queue is created as part of this operation and is set in the JMSReplyTO
header of the message.
This will only work with a default destination specified!
messageCreator
- callback to create a request messagenull
if the message could not be received,
for example due to a timeoutJmsException
- checked JMSException converted to unchecked@Nullable Message sendAndReceive(Destination destination, MessageCreator messageCreator) throws JmsException
MessageCreator
callback creates the message given a Session. A temporary
queue is created as part of this operation and is set in the JMSReplyTO
header of the message.destination
- the destination to send this message tomessageCreator
- callback to create a messagenull
if the message could not be received,
for example due to a timeoutJmsException
- checked JMSException converted to unchecked@Nullable Message sendAndReceive(String destinationName, MessageCreator messageCreator) throws JmsException
MessageCreator
callback creates the message given a Session. A temporary
queue is created as part of this operation and is set in the JMSReplyTO
header of the message.destinationName
- the name of the destination to send this message to
(to be resolved to an actual destination by a DestinationResolver)messageCreator
- callback to create a messagenull
if the message could not be received,
for example due to a timeoutJmsException
- checked JMSException converted to unchecked@Nullable <T> T browse(BrowserCallback<T> action) throws JmsException
action
- callback object that exposes the session/browser pairJmsException
- checked JMSException converted to unchecked@Nullable <T> T browse(Queue queue, BrowserCallback<T> action) throws JmsException
queue
- the queue to browseaction
- callback object that exposes the session/browser pairJmsException
- checked JMSException converted to unchecked@Nullable <T> T browse(String queueName, BrowserCallback<T> action) throws JmsException
queueName
- the name of the queue to browse
(to be resolved to an actual destination by a DestinationResolver)action
- callback object that exposes the session/browser pairJmsException
- checked JMSException converted to unchecked@Nullable <T> T browseSelected(String messageSelector, BrowserCallback<T> action) throws JmsException
messageSelector
- the JMS message selector expression (or null
if none).
See the JMS specification for a detailed definition of selector expressions.action
- callback object that exposes the session/browser pairJmsException
- checked JMSException converted to unchecked@Nullable <T> T browseSelected(Queue queue, String messageSelector, BrowserCallback<T> action) throws JmsException
queue
- the queue to browsemessageSelector
- the JMS message selector expression (or null
if none).
See the JMS specification for a detailed definition of selector expressions.action
- callback object that exposes the session/browser pairJmsException
- checked JMSException converted to unchecked@Nullable <T> T browseSelected(String queueName, String messageSelector, BrowserCallback<T> action) throws JmsException
queueName
- the name of the queue to browse
(to be resolved to an actual destination by a DestinationResolver)messageSelector
- the JMS message selector expression (or null
if none).
See the JMS specification for a detailed definition of selector expressions.action
- callback object that exposes the session/browser pairJmsException
- checked JMSException converted to unchecked