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, Sam Brannen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildExceptionMessage(jakarta.jms.JMSException ex) Build a descriptive exception message for the given JMSException, incorporating a linked exception's message if appropriate.static voidcloseConnection(@Nullable jakarta.jms.Connection con) Close the given JMS Connection and ignore any thrown exception.static voidcloseConnection(@Nullable jakarta.jms.Connection con, boolean stop) Close the given JMS Connection and ignore any thrown exception.static voidcloseMessageConsumer(@Nullable jakarta.jms.MessageConsumer consumer) Close the given JMS MessageConsumer and ignore any thrown exception.static voidcloseMessageProducer(@Nullable jakarta.jms.MessageProducer producer) Close the given JMS MessageProducer and ignore any thrown exception.static voidcloseQueueBrowser(@Nullable jakarta.jms.QueueBrowser browser) Close the given JMS QueueBrowser and ignore any thrown exception.static voidcloseQueueRequestor(@Nullable jakarta.jms.QueueRequestor requestor) Close the given JMS QueueRequestor and ignore any thrown exception.static voidcloseSession(@Nullable jakarta.jms.Session session) Close the given JMS Session and ignore any thrown exception.static voidcommitIfNecessary(jakarta.jms.Session session) Commit the Session if not within a JTA transaction.static JmsExceptionconvertJmsAccessException(jakarta.jms.JMSException ex) Convert the specified checkedJMSExceptionto a Spring runtimeJmsExceptionequivalent.static voidrollbackIfNecessary(jakarta.jms.Session session) Roll back 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 typical
finallyblocks 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 typical
finallyblocks 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 typical
finallyblocks 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 typical
finallyblocks 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 typical
finallyblocks 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 typical
finallyblocks 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 typical
finallyblocks in manual JMS code.- Parameters:
requestor- the JMS QueueRequestor to close (may benull)
-
commitIfNecessary
public static void commitIfNecessary(jakarta.jms.Session session) throws jakarta.jms.JMSException Commit the Session if not within a JTA transaction.- Parameters:
session- the JMS Session to commit- Throws:
jakarta.jms.JMSException- if committing failed
-
rollbackIfNecessary
public static void rollbackIfNecessary(jakarta.jms.Session session) throws jakarta.jms.JMSException Roll back the Session if not within a JTA transaction.- Parameters:
session- the JMS Session to rollback- Throws:
jakarta.jms.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 checkedJMSExceptionto a Spring runtimeJmsExceptionequivalent.- Parameters:
ex- the original checked JMSException to convert- Returns:
- the Spring runtime JmsException wrapping the given exception
-