简体   繁体   中英

Configuring Java Client for Hazelcast

I am trying to configure a JAVA client for Hazelcast. I have a web application deployed on tomcat servers. The example that I am following is this

Basic Clients Hazelcast . I have copied the code into my local machine and when I simply run it without running anything else and without the addAddress() step I get a java.net.ConnectionException. My doubts are:

1) What is the client in this case (I am assuming it is the web application that probably means I have to get the Hazelcast server up and running then what is to be done)?

2) How do I establish a link between the web app, the tomcat server and hazelcast cluster? The web app uses MongoDB as the backend. I was able to do a only MongoDB with Hazelcast integration but not the web app on tomcat server integration. What role does tomcat play here in this setup?

3) In the example what are the start.sh and stop.sh supposed to do? Where should I run them? If I simply open the git bash and run it. It doesn't seem to work.

I have looked at the documentation provided in the Hazelcast manual but I wasn't able to understand it as my current level of knowledge is woefully inadequate. If somebody could explain it to me or paste the links to some of the obvious stuff that I should know it would be great.

The answers are inline:

What is the client in this case(I am assuming it is the web application that probably means I have to get the Hazelcast server up and running then what is to be done)

The web application can be a Hazelcast client if you would like to use Hazelcast in client-server topology.

How do I establish a link between the web app, the tomcat server and hazelcast cluster. The web app uses MongoDB as the backend. I was able to do a only MongoDB with Hazelcast integration but not the web app on tomcat server integration. What role does tomcat play here in this setup.

Your web app runs in Tomcat server (web container) and the Hazelcast client you use in your web app can directly connect to the Hazelcast cluster members (server). You will just need to configure your client properly such as adding cluster member address by using clientConfig.getNetworkConfig().addAddress() API. Please see for more details about configuring client in this link: http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#configuring-java-client

In the example what are the start.sh and stop.sh supposed to do. Where should I run them. If I simply open the git bash and run it. It doesnt seem to work.

Those are sample start scripts for the sample client and member application. You don't need to use them in your application.

Please see the following guides for using Hazelcast in client-server topology:

https://hazelcast.org/getting-started-with-hazelcast/ http://docs.hazelcast.org/docs/latest/manual/html-single/index.html#getting-started-with-java-client

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM