users@glassfish.java.net

Re: GLASSFISH CLUSTER AND HTTPSESSIONLISTER

From: <glassfish_at_javadesktop.org>
Date: Wed, 26 Sep 2007 12:18:18 PDT

Hi Evarista:

You raise an interesting question. Glassfish behavior for HttpSessionListener is interpreted as a "fire at most once" semantic.

First a little background: HttpSessionListener does not respond to general changes to sessions but only to creation and invalidation of a session.

 void sessionCreated(HttpSessionEvent se)
          Notification that a session was created.
 void sessionDestroyed(HttpSessionEvent se)
          Notification that a session was invalidated.

The Tomcat behavior you describe is interesting and apparently helpful for your particular use case but it could easily be dangerous for other use cases.

For example, what if someone wrote in an implementation of HttpSessionListener that every time a session was created, you were billed $1.00 for a usage fee. In a one instance situation, you would be correctly billed, i.e. $1.00 per session creation. But on a 10 instance cluster, this behavior would bill you $10.00 per session creation.

At the root of this issue is that the Servlet spec was not written with clusters in mind. Some implementors have interpreted the behavior for clusters in one way (Tomcat) and others (Glassfish) in a different way. There is no right or wrong here - and no one behavior would be "correct" for all cases.

To answer your question, no it is not possible at present to configure a different behavior for HttpSessionListener in Glassfish.

To answer your second question, Project Shoal, which is incorporated in Glassfish for Group Member Service (GMS), has a distributed hashmap implementation for light weight use. See
https://shoal.dev.java.net/ for more details.
[Message sent by forum member 'lwhite' (lwhite)]

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