• Post Reply Bookmark Topic Watch Topic
  • New Topic

Singleton In EJB Clustered Servers ?  RSS feed

 
Chandra A Sekhar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Kyle's suggestion.
Furthermore, if performance is a concern with using Entity Beans then there are a number of different distributed caching products available.
 
Rob Misek
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of which is Tangosol's Coherence, a Clustered Caching Solution with both Replicated and Distributed flavors.
Later.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!