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);
}
}
Aggregations