public abstract class

JmsUtils

extends Object
java.lang.Object
   ↳ org.springframework.jms.support.JmsUtils

Class Overview

Generic utility methods for working with JMS. Mainly for internal use within the framework, but also useful for custom JMS access code.

Summary

Public Constructors
JmsUtils()
Public Methods
static String buildExceptionMessage(JMSException ex)
Build a descriptive exception message for the given JMSException, incorporating a linked exception's message if appropriate.
static void closeConnection(Connection con)
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 convertJmsAccessException(JMSException ex)
Convert the specified checked javax.jms.JMSException JMSException to a Spring runtime JmsException equivalent.
static void rollbackIfNecessary(Session session)
Rollback the Session if not within a JTA transaction.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public JmsUtils ()

Public Methods

public static String buildExceptionMessage (JMSException ex)

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
  • javax.jms.JMSException#getLinkedException()

public static void closeConnection (Connection con)

Close the given JMS Connection and ignore any thrown exception. This is useful for typical finally blocks in manual JMS code.

Parameters
con the JMS Connection to close (may be null)

public static void closeConnection (Connection con, boolean stop)

Close the given JMS Connection and ignore any thrown exception. This is useful for typical finally blocks in manual JMS code.

Parameters
con the JMS Connection to close (may be null)
stop whether to call stop() before closing

public static void closeMessageConsumer (MessageConsumer consumer)

Close the given JMS MessageConsumer and ignore any thrown exception. This is useful for typical finally blocks in manual JMS code.

Parameters
consumer the JMS MessageConsumer to close (may be null)

public static void closeMessageProducer (MessageProducer producer)

Close the given JMS MessageProducer and ignore any thrown exception. This is useful for typical finally blocks in manual JMS code.

Parameters
producer the JMS MessageProducer to close (may be null)

public static void closeQueueBrowser (QueueBrowser browser)

Close the given JMS QueueBrowser and ignore any thrown exception. This is useful for typical finally blocks in manual JMS code.

Parameters
browser the JMS QueueBrowser to close (may be null)

public static void closeQueueRequestor (QueueRequestor requestor)

Close the given JMS QueueRequestor and ignore any thrown exception. This is useful for typical finally blocks in manual JMS code.

Parameters
requestor the JMS QueueRequestor to close (may be null)

public static void closeSession (Session session)

Close the given JMS Session and ignore any thrown exception. This is useful for typical finally blocks in manual JMS code.

Parameters
session the JMS Session to close (may be null)

public static void commitIfNecessary (Session session)

Commit the Session if not within a JTA transaction.

Parameters
session the JMS Session to commit
Throws
if committing failed
JMSException

public static JmsException convertJmsAccessException (JMSException ex)

Convert the specified checked javax.jms.JMSException JMSException to a Spring runtime JmsException equivalent.

Parameters
ex the original checked JMSException to convert
Returns
  • the Spring runtime JmsException wrapping the given exception

public static void rollbackIfNecessary (Session session)

Rollback the Session if not within a JTA transaction.

Parameters
session the JMS Session to rollback
Throws
if committing failed
JMSException