-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Hello,
I have a Spring Boot application that has embedded Eureka server and Hazelcast instance that uses Eureka as a joiner point.
Sort of chicken and egg thing. Problem is how to configure both things right. Ideally Eureka should start first, then Hazelcast can start by using eureka one join strategy. However in practice that wan't an easy thing to do.
My application gets eureka-client configuration from properties file. use-classpath-eureka-client-props set to false.
That leads to an exception when application starts:
Caused by: java.lang.IllegalStateException: ConfigurationManager is already initialized with configuration com.netflix.config.ConcurrentCompositeConfiguration@427bbaac
at com.netflix.config.DynamicPropertyFactory.initWithConfigurationSource(DynamicPropertyFactory.java:147) ~[archaius-core-0.7.6.jar:0.7.6]
at com.hazelcast.eureka.one.PropertyBasedEurekaClientConfig.<init>(PropertyBasedEurekaClientConfig.java:57) ~[hazelcast-eureka-one-1.1.2.jar:na]
at com.hazelcast.eureka.one.EurekaOneDiscoveryStrategy.<init>(EurekaOneDiscoveryStrategy.java:181) ~[hazelcast-eureka-one-1.1.2.jar:na]
That happens because only one ConfigurationManager present in the application, Hazelcast fails to join cluster by using eureka one strategy and it drops down to use multicast joiner instead.
That can be fixed by changing the configuration source for eureka client by setting use-classpath-eureka-client-props to true. In this case Eureka client is looking for eureka-client.properties in a classpath and it instantiates a configuration manager by it. It works well, however this is not a convenient way to handle configurations IMO. As a workaround I have to rewrite eureka-client.properties with an accurate configuration every time application is started.
Is there any way how to avoid that ? Ideally I would like to use use-classpath-eureka-client-props=false approach, but it's impossible because of exception I posted above. It always happens even when I postponed Hazelcast initialization by wrapping Hazelcast instance by proxy.
Thanks.
Vlad