Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Hazelcast joiner to use Eureka that is running in the same application. #94

Open
exmortal opened this issue Nov 24, 2020 · 0 comments

Comments

@exmortal
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant