Eureka multiple defaultZone, CloudConfig and @Value annotation

Viewed 54

I'm using Spring Boot 2.4.4 and spring-cloud-starter-netflix-eureka-client 3.0.2.

Inside my code I use some @Value and @ConfigurationProperties, without providing default values, to bind properties and methods from a configuration file that has to be retrieved from the ConfigServer.

In the following picture a representation of my instances.

enter image description here

I register two instances of Eureka Server (spring-cloud-starter-netflix-eureka-server 3.0.2), one on port 8081 and the other on port 8082.

My MyMicroService's bootstrap contains both urls as defaultZone, point is that whenever the first Eureka is up and running everything works fine: both of the Eureka show that the microservice is registered, the ms is able to recover the configuration from the ConfigServer (also retrieved from Eureka). When the first Eureka is down, the microservice tries to connect to it then fail and an ERROR is raised since it wans't able to resolve a placeholder (inside a @Value annotation) then stops without trying the other Eureka url (8082).

enter image description here

I find it strange that it tries to start up the microservice before trying all the Eureka defaultZone URLs. Am I missing something?

Also, I can't give default values to those properties and in another microservice, without annotations, it works, it tries to connect to 8081, fails and then tries 8082.

Is there a configuration that specify to try all defaultZone before trying to evaluate @Value and @ConfigurationProperties annotations?

0 Answers
Related