Closed hannah23280 closed 3 years ago
Issue Description:
I manage to create a simple spring-boot based microservice that register itself with a running consul agent. But if i close the agent, and then started it again. I notice that the microservice will not retry register itself again. I done research online, but still could not find a solution to this. Is this the expected behavior?
Do note that i follow this https://cloud.spring.io/spring-cloud-consul/multi/multi_spring-cloud-consul-retry.html. By simply adding the below in my gradle.build implementation group: 'org.springframework.retry', name: 'spring-retry', version: '1.0.3.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-aop',
I expect the retry to just work for my spring boot based microservice. But its not working. *i would also like to know if the instruction provided by the above URL is still valid. If not, hopefully someone can provide a link to the correct instructions for me to follow. If still cannot, i can attach my sample codes here
What version of spring cloud are you using?
What version of spring cloud are you using?
Hi, version 2020.0.3
So what is the verdict? Does spring consul's current stable version able to support re-register itself after consul agent restarted
Resolved. need to add the below 2 properties spring.cloud.consul.discovery.heartbeat.enabled= true spring.cloud.consul.discovery.heartbeat.reregister-service-on-failure=true
I had a similar problem but I had to do sth more. My solution below - maybe will be helpful for someone:
Reregistration is performed when consul heartbeat request fails and ReregistrationPredicate is fullfilled. But default predicate only accepts HTTP status code 500. In my case HTTP status code was 404 - so I needed to write custom predicate, e.g. sth like:
@Bean
public ReregistrationPredicate reRegistrationPredicate() {
return e -> e.getStatusCode() >= 400;
}
Issue Description:
I manage to create a simple spring-boot based microservice that register itself with a running consul agent. But if i close the agent, and then started it again. I notice that the microservice will not retry register itself again. I done research online, but still could not find a solution to this. Is this the expected behavior?
Spring Boot: v2.5.1