i've some problems with hazelcast http session replication feature.
I'm trying to deploy a web application with hazelcast http session replication in a pair of tomcat 7.0.54 already in cluster (SimpleTcpCluster with a DeltaManager), running under java 1.7.0_25 with others non-hazelcast clustered applications.
i've some questions:
- is it possible to have hazelcast clsutered and non-hazelcast clsutered application in the same tomcat cluster?
- the application with hazelcast should be distributable? (by adding in it's web.xml like the others)
- the tomcat's in which the app is deployed shouldn't be in cluster? can i have other application clusterized with standard tomcat session replication in the same tomcat?
EDIT:
More detailed explanation of what i'm doing:
i'm trying to create a simple web app, with just one servlet that, at the first user request generate one new http session, and than, for each GET request will print the session id. this is the servlet code:
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("Get Method. Check Session...");
HttpSession session = req.getSession(false);
if (session==null) {
System.out.println("User with null session, generating one...");
session = req.getSession(true);
if (session==null)
System.out.println("Session can not be generated.");
}
if (session!=null)
System.out.println("Received GET request from session " + session.getId());
}
In order to introduce the hazelcast WM to get the session replicated among 2 tomcats, i've added to my project:
hazelcast-3.2.5.jar into WEB-INF folder
hazelcast-wm-3.2.5.jar into WEB-INF folder
standard hazelcast.xml into WEB-INF folder (exacly the same hazelcast.xml that is packaged within the ZIP archive of the hazelcast 3.2.5, into the bin folder)
added the hazelcast filter to my web.xml, exacly the same in the example in the official documentation
On the official documentation i didn't find any other configuration needed (http://hazelcast.org/docs/latest/manual/html/httpsessionclustering.html), and i met all requirements.
In front of both tomcats i have an HAproxy that balance the traffic (with stiky-session) between both nodes.
When both nodes start they join the cluster, and i have this log on both sides:
INFO: [192.168.0.68]:4701 [dev] [3.2.5]
Members [2] {
Member [192.168.0.68]:4701 this
Member [192.168.0.49]:4701
}
When i made the first request, i got, on the first node, this logs: Get Method. Check Session... User with null session, generating one... Received GET request from session HZ2F779DFA402A406E9ACCA3E0298B37F5
and each request after this one generate this logs:
Get Method. Check Session...
Received GET request from session HZ2F779DFA402A406E9ACCA3E0298B37F5
When i KILL this tomcat, the HAProxy start to send all request to the second one and i expected that the session will be the same (HZ2F779DFA402A406E9ACCA3E0298B37F5) but i got this logs:
Get Method. Check Session...
User with null session, generating one...
Received GET request from session HZB89D6CDC1CC94FDEBC82019BAAA9022E
Get Method. Check Session...
Received GET request from session HZB89D6CDC1CC94FDEBC82019BAAA9022E
why the session is changed? what i'm doing wrong?
this use case is so simple that probably i'm missing something, but i can't figure it out. there are others pre-requisite?
SOFTWARE USED:
hazelcast 3.2.5
tomcat 7.0.54
java 1.7.0_25