You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
then I checked the source code and found a bug.
The bug is come from spring-cloud-consul-discovery package's class org.springframework.cloud.consul.serviceregistry.ConsulServiceRegistry.
In this method public void register(ConsulRegistration reg),the original code is:
@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);
}
}
than I changed it like this:
@Override
public void register(ConsulRegistration reg) {
log.info("Registering service with consul: " + reg.getService());
try {
this.client.agentServiceRegister(reg.getService(), this.properties.getAclToken());
}
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);
}
try {
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);
}
}
Now when services is not registered successfully,the method will go to an exception,than I will add the registered services into the scheduler.
Maybe you can fix this,thank you.
The text was updated successfully, but these errors were encountered:
Serivices wont register automatically when consul-server is started after starting spring-cloud-consul
version:spring-cloud-consul-discovery 3.1.0
I already configured spring.cloud.consul.discovery.heartbeat like this
then I checked the source code and found a bug.
The bug is come from spring-cloud-consul-discovery package's class org.springframework.cloud.consul.serviceregistry.ConsulServiceRegistry.
In this method public void register(ConsulRegistration reg),the original code is:
than I changed it like this:
Now when services is not registered successfully,the method will go to an exception,than I will add the registered services into the scheduler.
Maybe you can fix this,thank you.
The text was updated successfully, but these errors were encountered: