Top Description Fields Constructors Methods
org.springframework.jms.support

public abstract Class JmsUtils

extends Object
Class Inheritance
Imports
jakarta.jms.Connection, .JMSException, .MessageConsumer, .MessageProducer, .QueueBrowser, .QueueRequestor, .Session, org.apache.commons.logging.Log, .LogFactory, org.springframework.jms.InvalidClientIDException, .InvalidDestinationException, .InvalidSelectorException, .JmsException, .JmsSecurityException, .MessageEOFException, .MessageFormatException, .MessageNotReadableException, .MessageNotWriteableException, .ResourceAllocationException, .TransactionInProgressException, .TransactionRolledBackException, .UncategorizedJmsException, org.springframework.lang.Nullable, org.springframework.util.Assert

Generic utility methods for working with JMS. Mainly for internal use within the framework, but also useful for custom JMS access code.
Authors
Juergen Hoeller, Sam Brannen
Since
1.1

Field Summary

Modifier and TypeField and Description
private static final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

the descriptive message String
buildExceptionMessage
(JMSException
the JMSException to build a message for
ex
)

Build a descriptive exception message for the given JMSException, incorporating a linked exception's message if appropriate.

public static void
closeConnection(Connection
the JMS Connection to close (may be null)
con
)

Close the given JMS Connection and ignore any thrown exception.

public static void
closeConnection(Connection
the JMS Connection to close (may be null)
con
,
boolean
whether to call stop() before closing
stop
)

Close the given JMS Connection and ignore any thrown exception.

public static void
closeMessageConsumer(MessageConsumer
the JMS MessageConsumer to close (may be null)
consumer
)

Close the given JMS MessageConsumer and ignore any thrown exception.

public static void
closeMessageProducer(MessageProducer
the JMS MessageProducer to close (may be null)
producer
)

Close the given JMS MessageProducer and ignore any thrown exception.

public static void
closeQueueBrowser(QueueBrowser
the JMS QueueBrowser to close (may be null)
browser
)

Close the given JMS QueueBrowser and ignore any thrown exception.

public static void
closeQueueRequestor(QueueRequestor
the JMS QueueRequestor to close (may be null)
requestor
)

Close the given JMS QueueRequestor and ignore any thrown exception.

public static void
closeSession(Session
the JMS Session to close (may be null)
session
)

Close the given JMS Session and ignore any thrown exception.

public static void
commitIfNecessary(Session
the JMS Session to commit
session
)

Commit the Session if not within a JTA transaction.

public static JmsException

Returns:

the Spring runtime JmsException wrapping the given exception
convertJmsAccessException
(JMSException
the original checked JMSException to convert
ex
)

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

public static void
rollbackIfNecessary(Session
the JMS Session to rollback
session
)

Roll back the Session if not within a JTA transaction.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
private static final Log logger

Constructor Detail

JmsUtilsback to summary
public JmsUtils()

Method Detail

buildExceptionMessageback to summary
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:JMSException

the JMSException to build a message for

Returns:String

the descriptive message String

See Also
jakarta.jms.JMSException#getLinkedException()
closeConnectionback to summary
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:Connection

the JMS Connection to close (may be null)

closeConnectionback to summary
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:Connection

the JMS Connection to close (may be null)

stop:boolean

whether to call stop() before closing

closeMessageConsumerback to summary
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:MessageConsumer

the JMS MessageConsumer to close (may be null)

closeMessageProducerback to summary
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:MessageProducer

the JMS MessageProducer to close (may be null)

closeQueueBrowserback to summary
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:QueueBrowser

the JMS QueueBrowser to close (may be null)

closeQueueRequestorback to summary
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:QueueRequestor

the JMS QueueRequestor to close (may be null)

closeSessionback to summary
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:Session

the JMS Session to close (may be null)

commitIfNecessaryback to summary
public static void commitIfNecessary(Session session) throws JMSException

Commit the Session if not within a JTA transaction.

Parameters
session:Session

the JMS Session to commit

Exceptions
JMSException:
if committing failed
convertJmsAccessExceptionback to summary
public static JmsException convertJmsAccessException(JMSException ex)

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

Parameters
ex:JMSException

the original checked JMSException to convert

Returns:JmsException

the Spring runtime JmsException wrapping the given exception

rollbackIfNecessaryback to summary
public static void rollbackIfNecessary(Session session) throws JMSException

Roll back the Session if not within a JTA transaction.

Parameters
session:Session

the JMS Session to rollback

Exceptions
JMSException:
if committing failed