users@glassfish.java.net

Re: Internal processes in EJB

From: <glassfish_at_javadesktop.org>
Date: Tue, 18 Nov 2008 08:58:39 PST

This sounds like a JCA use case to me, as that's really it's role -- integration of the JEE container with external systems (which is basically what you're doing).

The Stateful Beans are not really appropriate for your data storage, as Stateful Beans can not be shared across clients.

While an arbitrary client can get the Stateful Bean handle, in order to locate the Bean, and that handle can be shared, actual access to the Stateful Bean can NOT be shared. Specifically, if more than one client tries to access the Stateful Bean at the same time as another client, you will get an exception.

So, as a source of shared knowledge, the Stateful Bean is not the best component. It's really designed to handle the state for a single client.

If you're not running in a clustered environment, it's perfectly acceptable to use (for the time being) a static instance variable, as part of perhaps a Session Bean, to store your monitoring data. You will need to synchronize access to this shared resource yourself, but that's ok.

Write a JCA module that sends the raw monitoring data to an MDB (through a JMS queue). The data is maintained as a static member of a session bean. The MDB can call service methods on that session bean, and then the clients can also call that session bean. Of course if the session bean needs to persist anything to the DB, it can do that as well.

If you're in a clustered environment, then you'll need to explore some kind of shared cache implementation.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=317375