I am in need of implementing a distributed object pool. That is, I need for multiple JVMs running on separate hardware to be able to access a finite collection of objects. The pool should manage the concurrency and contention for the objects such that if the pool is emptied, the JVM code requesting a new object should appear to block until one becomes available again. Was thinking of trying to use JMS to implement something like this, but not sure if I'm going down the right path with that. Has anyone else implemented something like this? Is there a library or tool that would help here? Looked at Apache Commons Pool, but it doesn't appear to support the distributed use case I've outlined... Also looked at Semaphore, but same thing again...
What exactly do you mean by "access a finite collection of objects" ?
Are these serialized Java objects that you want to pass around as needed? If so it sounds like a JavaSpaces application to me.
The GigaSpaces developer edition would be my choice. A central JavaSpaces manager can control access to serialized objects using very flexible rules.
There is some similarity to JMS but with much better control.
Joined: Aug 23, 2005
Yes, sorry, they would be serializable java objects. Basically, we have an application that we have acquired a limited number of licenses for, and we have applications that run on different machines that need to interact with the software and need to login. So, it would be nice to have these "floating" licenses that separate JVM's could access. The object pool, perhaps GigaSpaces, would manage the concurrency so that each "license" object is only in use once at a time and client apps would block until one becomes available... The object itself could be a very simple POJO that simply contains the username/password in it with appropriate accessors... I hope this makes things a little clearer, but I'm going to investigate GigaSpaces now. Does it still sound like an appropriate solution?
Author and all-around good cowpoke
Joined: Mar 22, 2000
That should be easily done with Gigaspaces / JavaSpaces.