Search in sources :

Example 1 with CamelJmsTemplate

use of org.apache.camel.component.jms.JmsConfiguration.CamelJmsTemplate in project camel by apache.

the class JmsProducer method testConnectionOnStartup.

/**
     * Pre tests the connection before starting the listening.
     * <p/>
     * In case of connection failure the exception is thrown which prevents Camel from starting.
     *
     * @throws FailedToCreateProducerException is thrown if testing the connection failed
     */
protected void testConnectionOnStartup() throws FailedToCreateProducerException {
    try {
        CamelJmsTemplate template = (CamelJmsTemplate) getInOnlyTemplate();
        if (log.isDebugEnabled()) {
            log.debug("Testing JMS Connection on startup for destination: " + template.getDefaultDestinationName());
        }
        Connection conn = template.getConnectionFactory().createConnection();
        JmsUtils.closeConnection(conn);
        log.debug("Successfully tested JMS Connection on startup for destination: " + template.getDefaultDestinationName());
    } catch (Exception e) {
        throw new FailedToCreateProducerException(getEndpoint(), e);
    }
}
Also used : FailedToCreateProducerException(org.apache.camel.FailedToCreateProducerException) CamelJmsTemplate(org.apache.camel.component.jms.JmsConfiguration.CamelJmsTemplate) Connection(javax.jms.Connection) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) JMSException(javax.jms.JMSException) FailedToCreateProducerException(org.apache.camel.FailedToCreateProducerException) RuntimeExchangeException(org.apache.camel.RuntimeExchangeException)

Aggregations

RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 Connection (javax.jms.Connection)1 JMSException (javax.jms.JMSException)1 FailedToCreateProducerException (org.apache.camel.FailedToCreateProducerException)1 RuntimeExchangeException (org.apache.camel.RuntimeExchangeException)1 CamelJmsTemplate (org.apache.camel.component.jms.JmsConfiguration.CamelJmsTemplate)1