Consider the following (hugely simplified) scenario:
We have various clients accessing a server application. The server
might be clustered. A client wants to know how many clients are
connected to the server.
Is the next design OK? Are there any flaws in it? Is there a better
design? Any help/comments are appretiated.
The clients call Stateless Session Bean methods to get that info. In
the static initializer of the SLSB we do a lookup of a Stateful
Session Bean (is that possible?) that we later plan to use as a
singleton. Store the JNDI handle in a static variable of the SLSB and
use that handle to get the SFSB whenever it's needed to get the count.
(We access the counter in the SFSB.)
-- We cannot use simply SFSB's 'cause they're bound to a client
session and are instantiated for every client.
-- We cannot use simply static variables, for they're unique only
inside a JVM or ClassLoader. Remember that the server could be
clustered. The data should be shared betwenn clustered server
instances.
-- We don't really want to use Entity Beans to persist this counter
data in a database...
Hope this makes sense...
ifly - 26 Aug 2004 15:45 GMT
I am interested in solving the same problem.
I currently have a solution involving JMX and WebLogic cluster.
1-create dynamic Mbean with synchronized methods
2-register with WL admin server as MBean agent/manager
3-all managed servers/users in cluster have access to this singleton
4-as clients log in/out they can invoke addUser/deleteUser methods on
dynamic mbean. They can also read currentUserCount.
PROBLEM:Single point of failure on admin server.
Looking for a simpler solution as you described above, OR
figuring out how to have dynamic MBean replicated in cluster so that each
managed server uses a local replicated copy--not sure how to achieve this
yet...