Example usage for org.springframework.jms.support JmsUtils buildExceptionMessage

List of usage examples for org.springframework.jms.support JmsUtils buildExceptionMessage

Introduction

In this page you can find the example usage for org.springframework.jms.support JmsUtils buildExceptionMessage.

Prototype

public static String buildExceptionMessage(JMSException ex) 

Source Link

Document

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

Usage

From source file:org.apache.servicemix.jbi.cluster.requestor.AbstractJmsRequestorPool.java

/**
 * Handle the given exception that arose during setup of a listener.
 * Called for every such exception in every concurrent listener.
 * <p>The default implementation logs the exception at error level
 * if not recovered yet, and at debug level if already recovered.
 * Can be overridden in subclasses./* w w w .  j a v  a 2  s. c om*/
 * @param ex the exception to handle
 * @param alreadyRecovered whether a previously executing listener
 * already recovered from the present listener setup failure
 * (this usually indicates a follow-up failure than can be ignored
 * other than for debug log purposes)
 * @see #recoverAfterListenerSetupFailure()
 */
protected void handleListenerSetupFailure(Throwable ex, boolean alreadyRecovered) {
    if (ex instanceof JMSException) {
        invokeExceptionListener((JMSException) ex);
    }
    if (ex instanceof SharedConnectionNotInitializedException) {
        if (!alreadyRecovered) {
            logger.debug("JMS message listener invoker needs to establish shared Connection");
        }
    } else {
        // Recovery during active operation..
        if (alreadyRecovered) {
            logger.debug("Setup of JMS message listener invoker failed - already recovered by other invoker",
                    ex);
        } else {
            StringBuffer msg = new StringBuffer();
            msg.append("Setup of JMS message listener invoker failed for destination '");
            msg.append(getDestinationDescription()).append("' - trying to recover. Cause: ");
            msg.append(ex instanceof JMSException
                    ? JmsUtils.buildExceptionMessage(fixForSpring5470((JMSException) ex))
                    : ex.getMessage());
            if (logger.isDebugEnabled()) {
                logger.info(msg, ex);
            } else {
                logger.info(msg);
            }
        }
    }
}

From source file:org.apache.servicemix.jbi.cluster.requestor.AbstractJmsRequestorPool.java

/**
 * Refresh the underlying Connection, not returning before an attempt has been
 * successful. Called in case of a shared Connection as well as without shared
 * Connection, so either needs to operate on the shared Connection or on a
 * temporary Connection that just gets established for validation purposes.
 * <p>The default implementation retries until it successfully established a
 * Connection, for as long as this message listener container is active.
 * Applies the specified recovery interval between retries.
 * @see #setRecoveryInterval/* ww w . ja  v a  2 s .c o  m*/
 */
protected void refreshConnectionUntilSuccessful() {
    while (isRunning()) {
        try {
            if (sharedConnectionEnabled()) {
                refreshSharedConnection();
            } else {
                Connection con = createConnection();
                JmsUtils.closeConnection(con);
            }
            logger.info("Successfully refreshed JMS Connection");
            break;
        } catch (Exception ex) {
            StringBuffer msg = new StringBuffer();
            msg.append("Could not refresh JMS Connection for destination '");
            msg.append(getDestinationDescription()).append("' - retrying in ");
            msg.append(this.recoveryInterval).append(" ms. Cause: ");
            msg.append(ex instanceof JMSException
                    ? JmsUtils.buildExceptionMessage(fixForSpring5470((JMSException) ex))
                    : ex.getMessage());
            if (logger.isDebugEnabled()) {
                logger.info(msg, ex);
            } else if (logger.isInfoEnabled()) {
                logger.info(msg);
            }
        }
        sleepInbetweenRecoveryAttempts();
    }
}