Hazelcast Client configuration using Eureka not working...

596 views
Skip to first unread message

ama...@gmail.com

unread,
Apr 24, 2019, 3:38:53 AM4/24/19
to Hazelcast
Hello,

I am using Eureka for service discovery in my microservices. I have setup the Hazelcast members via Eureka discovery and it is working all good.
Now, I am trying to setup a Hazelcast client and it should discover the member cluster using Eureka. I have done below configuration for client:

    public ClientConfig buildConfiguration()
    {
        ClientConfig config = new ClientConfig();
        ClientNetworkConfig netConfig = config.getNetworkConfig();
        netConfig.setConnectionAttemptLimit(0); // try forever for connecting with server cluster.
        
        // configure Eureka
        netConfig.getEurekaConfig().setEnabled(true).setProperty("namespace", "hz_cache")
                .setProperty("use-classpath-eureka-client-props", "false").setProperty("shouldUseDns", "false")
                .setProperty("name", "hazelcast_cache").setProperty("serviceUrl.default", eurekaURL);
        return config;
    }

But, the discovery does not happen through Eureka, it always happens through multicast. Plus, the client tries to register itself as a separate member in the Eureka.

Please help me to solve the issue.

Thanks.

Rafal Leszko

unread,
Apr 24, 2019, 5:46:20 AM4/24/19
to haze...@googlegroups.com
Hi,

You can follow this up the "Hazelcast Only" scenario. This will set up the Hazelcast cluster.

Then, I checked the client by modifying hazlecast-only project and changed the Maven dependency `hazelcast` => `hazelcast-all`. Then, the Hazelcast configuration to the following.
@Bean
public ClientConfig hazelcastConfig() {

ClientConfig config = new ClientConfig();
  config.getNetworkConfig().getEurekaConfig()
.setEnabled(true)
.setProperty("self-registration", "false")
.setProperty("namespace", "hazelcast");

return config;
}

Client discovered the Hazelcast cluster correctly.

Hope it helps,
Rafał

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/dd94ca9d-45bb-4cca-a99a-1ebc38b34d45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Rafał Leszko
Software Engineer
@RafalLeszko

ama...@gmail.com

unread,
Apr 24, 2019, 9:20:18 AM4/24/19
to Hazelcast
Could you post the content of the console? I doubt if the client connected to the cluster through Eureka discovery. On my machine the client gets connected with cluster. But when I deploy the cluster on a separate machine (or on docker), the client is not able to connect. Looking at the console, the client is not using Eureka to find out cluster at all.
Please suggest if I am missing anything here. I have exactly the same code as you posted above.

Thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to haze...@googlegroups.com.

Rafal Leszko

unread,
Apr 24, 2019, 9:32:45 AM4/24/19
to haze...@googlegroups.com
Sure, here's my output. It looks like it connects via Eureka.

Maybe your issue is somewhere in the Docker's networking? Check this: https://github.com/hazelcast/hazelcast-docker#hazelcast-hello-world

Cheers,
Rafał

2019-04-24 09:41:35.345  INFO 2247 --- [           main] .p.EurekaConfigBasedInstanceInfoProvider : Setting initial instance status as: STARTING
2019-04-24 09:41:35.370  WARN 2247 --- [           main] c.n.config.util.ConfigurationUtils       : jar:file:/mnt/c/Users/rafal/Hazelcast/repos/hazelcast-code-samples/hazelcast-integration/eureka/springboot-embedded/hazelcast-client/target/hazelcast-client-0.1-SNAPSHOT.jar!/BOOT-INF/classes!/eureka-client.properties is already loaded
2019-04-24 09:41:35.522  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2019-04-24 09:41:36.381  INFO 2247 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-04-24 09:41:36.385  INFO 2247 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-04-24 09:41:36.953  INFO 2247 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-04-24 09:41:36.956  INFO 2247 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-04-24 09:41:37.752  INFO 2247 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-04-24 09:41:37.875  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2019-04-24 09:41:37.878  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2019-04-24 09:41:37.883  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2019-04-24 09:41:37.885  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2019-04-24 09:41:37.894  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2019-04-24 09:41:37.910  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2019-04-24 09:41:37.929  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2019-04-24 09:41:38.965  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2019-04-24 09:41:38.981  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Not registering with Eureka server per configuration
2019-04-24 09:41:39.010  INFO 2247 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1556098899005 with initial instances count: 2
2019-04-24 09:41:39.020  INFO 2247 --- [           main] c.h.s.d.integration.DiscoveryService     : hz.client_0 [dev] [3.12] Waiting for registration with Eureka...
2019-04-24 09:41:39.039  INFO 2247 --- [           main] c.h.s.d.integration.DiscoveryService     : hz.client_0 [dev] [3.12] Registered in Eureka
2019-04-24 09:41:39.147  INFO 2247 --- [           main] c.h.client.spi.ClientInvocationService   : hz.client_0 [dev] [3.12] Running with 2 response threads, dynamic=false
2019-04-24 09:41:39.502  INFO 2247 --- [           main] com.hazelcast.core.LifecycleService      : hz.client_0 [dev] [3.12] HazelcastClient 3.12 (20190409 - 915d83a) is STARTING
2019-04-24 09:41:39.513  INFO 2247 --- [           main] com.hazelcast.core.LifecycleService      : hz.client_0 [dev] [3.12] HazelcastClient 3.12 (20190409 - 915d83a) is STARTED
2019-04-24 09:41:39.750  INFO 2247 --- [ient_0.cluster-] c.h.c.c.nio.ClusterConnectorService      : hz.client_0 [dev] [3.12] Trying to connect to cluster with name: dev
2019-04-24 09:41:39.755  INFO 2247 --- [ient_0.cluster-] c.h.s.d.integration.DiscoveryService     : hz.client_0 [dev] [3.12] Waiting for registration with Eureka...
2019-04-24 09:41:39.762  INFO 2247 --- [ient_0.cluster-] c.h.s.d.integration.DiscoveryService     : hz.client_0 [dev] [3.12] Registered in Eureka
2019-04-24 09:41:39.800  INFO 2247 --- [ient_0.cluster-] c.h.c.c.nio.ClusterConnectorService      : hz.client_0 [dev] [3.12] Trying to connect to [10.0.0.86]:5703 as owner member
2019-04-24 09:41:40.121  INFO 2247 --- [nt_0.internal-1] c.h.c.c.ClientConnectionManager          : hz.client_0 [dev] [3.12] Setting ClientConnection{alive=true, connectionId=1, channel=NioChannel{/10.0.0.86:49371->/10.0.0.86:5703}, remoteEndpoint=[10.0.0.86]:5703, lastReadTime=2019-04-24 09:41:40.095, lastWriteTime=2019-04-24 09:41:40.001, closedTime=never, connected server version=3.12} as owner with principal ClientPrincipal{uuid='86e1fdfa-1cda-4523-ae6b-a0e46e4c2454', ownerUuid='7843aafb-be5c-4f18-baf0-027807a956a9'}
2019-04-24 09:41:40.133  INFO 2247 --- [nt_0.internal-1] c.h.c.c.ClientConnectionManager          : hz.client_0 [dev] [3.12] Authenticated with server [10.0.0.86]:5703, server version:3.12 Local address: /10.0.0.86:49371
2019-04-24 09:41:40.297  INFO 2247 --- [lient_0.event-1] c.h.c.spi.impl.ClientMembershipListener  : hz.client_0 [dev] [3.12]

Members [2] {
        Member [10.0.0.86]:5703 - 7843aafb-be5c-4f18-baf0-027807a956a9
        Member [10.0.0.86]:5701 - b8d7683f-f07d-4a82-9893-0bc3b51e066f
}

To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.

To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.

For more options, visit https://groups.google.com/d/optout.

amey pande

unread,
Apr 24, 2019, 9:36:34 AM4/24/19
to haze...@googlegroups.com
Thanks for quick response Rafal. I think that the connection is not through Eureka here. Any chance we can talk on Gmail phone call? I want to show  you my configuration. There's nothing wrong with Docker networking as I run the services in docker swarm where all the services run under same network.

You received this message because you are subscribed to a topic in the Google Groups "Hazelcast" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hazelcast/X1tc-EcG0Vc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hazelcast+...@googlegroups.com.

To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.

Rafal Leszko

unread,
Apr 24, 2019, 9:41:35 AM4/24/19
to haze...@googlegroups.com
Then, could I ask you to create GH issue here:  https://github.com/hazelcast/hazelcast-eureka with the description and how to reproduce it?
It will make us quicker to resolve the issue then.

Cheers,
Rafał


For more options, visit https://groups.google.com/d/optout.

amey pande

unread,
Apr 24, 2019, 9:56:44 AM4/24/19
to haze...@googlegroups.com
Thanks.

Please let me know if there's a quick fix which I can try out.

Thank you. 

Reply all
Reply to author
Forward
0 new messages