On Saturday 10 April 2004 21:48, Mike Duffy wrote:

Hi,

> I've read documentation for The Tomcat 5 Servlet/JSP Container:
> Clustering/Session Replication HOW-TO
> http://jakarta.apache.org/tomcat/tomcat-5.0-doc/cluster-howto.html
>
> I understand clustering for individual user sessions.  Are there any
> correlated methods for clustering application scope objects?

AFAIK there's nothing in the Servlet API specifications in this
direction. Sessions may be swapped in and out by several
different means (serialization or database), but application
scope information is kept individually for each JVM.

> The J2EE API for the Interface ServletContext states, "In the case of
> a web application marked "distributed" in its deployment descriptor,
> there will be one context instance for each virtual machine. In this
> situation, the context cannot be used as a location to share global
> information (because the information won't be truly global). Use an
> external resource like a database instead."

Yes. But then, it makes no difference whether your application
is marked as 'distributable' or not when considering application
scope objects. Application scope is always limited to a single
JVM. 'Distributed' is about sessions only.

> Rather than use a database, what I would like to be able to do is
> make a call to
>
>     servlet.getServletContext().setAttribute(key, object);
>
> and have the object stored in the application scope of all servers in
> the cluster.

That surely would be desirable, but I don't know of any
'official', declarative means to achieve such behavior.
Then: automatically synchronizing application scopes
between several JVM instances would cause a lot of
additional synchronization troubles - who determines
what's the actual system state at a given point, e.g.
if you update an application scope object (that is
globally shared) on one server, and another user
does likewise on a second one, what should be
the end result? And so on.

> I know that EJBs were designed to serve this purpose; however, I
> would like to bypass the overhead and complexities of EJBs.

EJBs live in the backend and are independant from
the web tier. Looking at the problem from a 
web tier view (which is what Struts is about),
it should not make any difference whether the
information comes directly from a database
in the end or from an EJB tier in-between.
That's transparent. Anyway, using EJBs
won't solve your problem in the end, for
it's an entirely web tier specific issue,
and EJBs are not part of that.   

> If there isn't a switch that can be flipped in Tomcat, there might be
> a way to create a lightweight JMS administration class to serve this
> purpose.  Has anyone tried this?

There is no switch (remember the spoon
boy in Matrix I ? :-). But the JMS idea is
interesting. Never actually tried it, but
of course, you can always handle
application specific logic programma-
tically, including using JMS for updating
application scopes in a distributed 
environment. But I never tried.

> If the answer to this question is RTFM, please send a link; I've
> looked through the documentation and I can't seem to find a clear
> reference.
>
> Thanks for your time and consideration.

Just some thoughts that came to me
on early Easter Sunday :-) Let's better
say: night; it's 2:16 local time here. So
I should better go to bed.

> Mike

HTH,
-- Chris.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to