Search in sources :

Example 1 with ConsulException

use of com.ecwid.consul.ConsulException in project spring-cloud-consul by spring-cloud.

the class ConsulServiceRegistry method register.

@Override
public void register(ConsulRegistration reg) {
    log.info("Registering service with consul: " + reg.getService());
    try {
        this.client.agentServiceRegister(reg.getService(), this.properties.getAclToken());
        NewService service = reg.getService();
        if (this.heartbeatProperties.isEnabled() && this.ttlScheduler != null && service.getCheck() != null && service.getCheck().getTtl() != null) {
            this.ttlScheduler.add(reg.getService());
        }
    } catch (ConsulException e) {
        if (this.properties.isFailFast()) {
            log.error("Error registering service with consul: " + reg.getService(), e);
            ReflectionUtils.rethrowRuntimeException(e);
        }
        log.warn("Failfast is false. Error registering service with consul: " + reg.getService(), e);
    }
}
Also used : ConsulException(com.ecwid.consul.ConsulException) NewService(com.ecwid.consul.v1.agent.model.NewService)

Aggregations

ConsulException (com.ecwid.consul.ConsulException)1 NewService (com.ecwid.consul.v1.agent.model.NewService)1