InterviewSolution
Saved Bookmarks
| 1. |
How to stop a Spring Boot based microservices at startup if it can not connect to the Config server during bootstrap? |
|
Answer» If you want to halt the service when it is not ABLE to locate the CONFIG-server during bootstrap, then you need to configure the following property in microservice’s bootstrap.yml: spring: cloud: config: fail-fast: trueUsing this configuration will make microservice startup fail with an exception when config-server is not reachable during bootstrap. We can enable a retry MECHANISM where microservice will retry 6 times before THROWING an exception. We just need to ADD spring-retry and spring-boot-starter-aop to the classpath to enable this feature. build.gradle:- ... dependencies { compile('org.springframework.boot:spring-boot-starter-aop') compile('org.springframework.retry:spring-retry') ... } |
|