Package org.springframework.jms.support
Class JmsUtils
java.lang.Object
org.springframework.jms.support.JmsUtils
Generic utility methods for working with JMS. Mainly for internal use
within the framework, but also useful for custom JMS access code.
- Since:
- 1.1
- Author:
- Juergen Hoeller
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Build a descriptive exception message for the given JMSException, incorporating a linked exception's message if appropriate.static void
Close the given JMS Connection and ignore any thrown exception.static void
closeConnection
(Connection con, boolean stop) Close the given JMS Connection and ignore any thrown exception.static void
closeMessageConsumer
(MessageConsumer consumer) Close the given JMS MessageConsumer and ignore any thrown exception.static void
closeMessageProducer
(MessageProducer producer) Close the given JMS MessageProducer and ignore any thrown exception.static void
closeQueueBrowser
(QueueBrowser browser) Close the given JMS QueueBrowser and ignore any thrown exception.static void
closeQueueRequestor
(QueueRequestor requestor) Close the given JMS QueueRequestor and ignore any thrown exception.static void
closeSession
(Session session) Close the given JMS Session and ignore any thrown exception.static void
commitIfNecessary
(Session session) Commit the Session if not within a JTA transaction.static JmsException
Convert the specified checkedJMSException
to a Spring runtimeJmsException
equivalent.static void
rollbackIfNecessary
(Session session) Rollback the Session if not within a JTA transaction.
-
Constructor Details
-
JmsUtils
public JmsUtils()
-
-
Method Details
-
closeConnection
Close the given JMS Connection and ignore any thrown exception. This is useful for typicalfinally
blocks in manual JMS code.- Parameters:
con
- the JMS Connection to close (may benull
)
-
closeConnection
Close the given JMS Connection and ignore any thrown exception. This is useful for typicalfinally
blocks in manual JMS code.- Parameters:
con
- the JMS Connection to close (may benull
)stop
- whether to callstop()
before closing
-
closeSession
Close the given JMS Session and ignore any thrown exception. This is useful for typicalfinally
blocks in manual JMS code.- Parameters:
session
- the JMS Session to close (may benull
)
-
closeMessageProducer
Close the given JMS MessageProducer and ignore any thrown exception. This is useful for typicalfinally
blocks in manual JMS code.- Parameters:
producer
- the JMS MessageProducer to close (may benull
)
-
closeMessageConsumer
Close the given JMS MessageConsumer and ignore any thrown exception. This is useful for typicalfinally
blocks in manual JMS code.- Parameters:
consumer
- the JMS MessageConsumer to close (may benull
)
-
closeQueueBrowser
Close the given JMS QueueBrowser and ignore any thrown exception. This is useful for typicalfinally
blocks in manual JMS code.- Parameters:
browser
- the JMS QueueBrowser to close (may benull
)
-
closeQueueRequestor
Close the given JMS QueueRequestor and ignore any thrown exception. This is useful for typicalfinally
blocks in manual JMS code.- Parameters:
requestor
- the JMS QueueRequestor to close (may benull
)
-
commitIfNecessary
Commit the Session if not within a JTA transaction.- Parameters:
session
- the JMS Session to commit- Throws:
JMSException
- if committing failed
-
rollbackIfNecessary
Rollback the Session if not within a JTA transaction.- Parameters:
session
- the JMS Session to rollback- Throws:
JMSException
- if committing failed
-
buildExceptionMessage
Build a descriptive exception message for the given JMSException, incorporating a linked exception's message if appropriate.- Parameters:
ex
- the JMSException to build a message for- Returns:
- the descriptive message String
- See Also:
-
convertJmsAccessException
Convert the specified checkedJMSException
to a Spring runtimeJmsException
equivalent.- Parameters:
ex
- the original checked JMSException to convert- Returns:
- the Spring runtime JmsException wrapping the given exception
-