Search in sources :

Example 1 with HostUnavailableException

use of org.apache.camel.component.cm.exceptions.HostUnavailableException in project camel by apache.

the class CMProducer method doStart.

@Override
protected void doStart() throws Exception {
    // log at debug level for singletons, for prototype scoped log at trace
    // level to not spam logs
    log.debug("Starting CMProducer");
    final CMConfiguration configuration = getConfiguration();
    if (configuration.isTestConnectionOnStartup()) {
        try {
            log.debug("Checking connection - {}", getEndpoint().getCMUrl());
            HttpClientBuilder.create().build().execute(new HttpHead(getEndpoint().getCMUrl()));
            log.debug("Connection to {}: OK", getEndpoint().getCMUrl());
        } catch (final Exception e) {
            throw new HostUnavailableException(String.format("Connection to %s: NOT AVAILABLE", getEndpoint().getCMUrl()), e);
        }
    }
    // keep starting
    super.doStart();
    log.debug("CMProducer started");
}
Also used : HostUnavailableException(org.apache.camel.component.cm.exceptions.HostUnavailableException) HttpHead(org.apache.http.client.methods.HttpHead) InvalidPayloadRuntimeException(org.apache.camel.InvalidPayloadRuntimeException) HostUnavailableException(org.apache.camel.component.cm.exceptions.HostUnavailableException)

Aggregations

InvalidPayloadRuntimeException (org.apache.camel.InvalidPayloadRuntimeException)1 HostUnavailableException (org.apache.camel.component.cm.exceptions.HostUnavailableException)1 HttpHead (org.apache.http.client.methods.HttpHead)1