We are trying to implement a system in which we have Course and Student Objects, each student randomly registers in to some course however each course has a constraint that it can only accommodate 16 students,if it exceeds we will create a new course instance and start populating the new Course object. We are worried about using any Singleton Pattern for this kind of system as we expect our system has to scale down for a large traffic which means we have to use clustering for appservers. We know for sure that in a clustered environment we can not use this singleton pattern as each JVM will end up with their own version of it. One solution we came up with is using a JMS queue and making our CourseManager(Singleton) to listen to this JMS queue so that any update on one CourseManager instance is propageted to other Clustered instances via JMS. Is there any other simpler way we can solve this problem of keeping two objects in a clustered environment in sync with each other ? or for that matter is there a way we can implement singleton across clustered servers ? Any input is well appreciated, Thanks in advance Chandra
No there isn't an easier way to have singletons across a cluster. You've just rediscovered the Propogate Cache Updates pattern. It works. However, I'm not convinced you need this pattern to solve your problem. Why not just implement these things as Entity beans and let the database handle these problems? Kyle [ January 09, 2003: Message edited by: Kyle Brown ]
I agree with Kyle. I don't understand why a Singleton is being used to solve the problem. Instead of making a Course keep track of number of students registered AND create new a course, you should probably model the Course as an entity bean and create a CourseManager that handles registration and creation of additional course entities. Of course there may be better design approaches, but the bottom line is, I am unable to understand how a Singleton is helping you solve the problem :roll:
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
One of which is Tangosol's Coherence, a Clustered Caching Solution with both Replicated and Distributed flavors. Later.
<a href="http://www.tangosol.com" target="_blank" rel="nofollow">www.tangosol.com</a><br /><a href="http://www.tangosol.com/coherence.jsp" target="_blank" rel="nofollow">Coherence:</a> Easily share live data across a cluster!
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop