Search in sources :

Example 1 with LoggingExceptionHandler

use of org.apache.camel.support.LoggingExceptionHandler in project camel by apache.

the class SjmsEndpoint method createConnectionResource.

protected ConnectionResource createConnectionResource(Object source) {
    if (getConnectionFactory() == null) {
        throw new IllegalArgumentException(String.format("ConnectionResource or ConnectionFactory must be configured for %s", this));
    }
    try {
        logger.debug("Creating ConnectionResource with connectionCount: {} using ConnectionFactory", getConnectionCount(), getConnectionFactory());
        // We always use a connection pool, even for a pool of 1
        ConnectionFactoryResource connections = new ConnectionFactoryResource(getConnectionCount(), getConnectionFactory(), getComponent().getConnectionUsername(), getComponent().getConnectionPassword(), getComponent().getConnectionClientId(), getComponent().getConnectionMaxWait(), getComponent().isConnectionTestOnBorrow());
        if (exceptionListener != null) {
            connections.setExceptionListener(exceptionListener);
        } else {
            // add a exception listener that logs so we can see any errors that happens
            ExceptionListener listener = new SjmsLoggingExceptionListener(new LoggingExceptionHandler(getCamelContext(), source.getClass()), isErrorHandlerLogStackTrace());
            connections.setExceptionListener(listener);
        }
        connections.fillPool();
        return connections;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : LoggingExceptionHandler(org.apache.camel.support.LoggingExceptionHandler) ConnectionFactoryResource(org.apache.camel.component.sjms.jms.ConnectionFactoryResource) ExceptionListener(javax.jms.ExceptionListener)

Aggregations

ExceptionListener (javax.jms.ExceptionListener)1 ConnectionFactoryResource (org.apache.camel.component.sjms.jms.ConnectionFactoryResource)1 LoggingExceptionHandler (org.apache.camel.support.LoggingExceptionHandler)1