• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to replicate Singleton Data to all servers in Cluster

 
Venkateswara Rao
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to replicate Singleton Data to all servers in Cluster.
I have Singleton class contains Hashtable, which will be updated dynamically. I want this singleton class data should be replicated to all servers in Cluster.
If all servers running in same JVM then there is no problem. One instance of singleton class exists and used by all servere in cluster.
If all servers in Cluster may not run in same JVM. In this case how to replicate this singleton class data.
I tell you situation where i am using Singleton class. I have request response scenerio. When i got the request I creates request ID and putting (requestId, (Request,URL))into singleton class wrpped with Hashtable. When i got Response extract requestID from Response and using requestID get the URL from Hashtable where to push this Response. Onece i push Response to URL then i delete requestID entry from Hashtable.
Problem is If request come to server1(in cluster) and Response for that request may come to another server say server2(In same cluster but different JVM). Because of Different JVMs Singleton Data(hashtable data) may not same.
Thanks and Regards
Venkateswara Rao
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds like a situation to store session state on the server between requests. I am not sure why you would want to go thru all the trouble of coding your own solution when J2EE has a perfectly good solution in the form of the HttpSession. Using an HttpSession you doing need to worry about generating and tracking "request ids" because this is already done for you. Furthermore, every major Application Server supports In-Memory Replication of HttpSession data in a cluster. However, it should be noted that the licenses for this tend to be fairly expensive for most vendors.
If all you want is a distributed object cache then there are other options. For example, Tangosol's Coherence is an excellent product.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!