[jboss-dev-forums] [Design of Clustering on JBoss] - Re: Removing SFSB in HttpSessionListener

tkimura@redhat.com do-not-reply at jboss.com
Wed Sep 10 20:10:40 EDT 2008


There are 3 scenarios the sessionDestroyed() method is called:

* Application is undeployed

This is the problem. We need to keep SFSBs here.

However, if the application holds local resources like FileInputStream/FileOutputStream within non-SFSB Seam component and relies on the @Destroy method for releasing those resources, it could be leak. If it's implemented within SFSBs, it would be released when SFSBs get timed out.

* Sesssion timeout

Typically the SFSBs timeout and conversations timeout are lower than session timeout, so it would be cleaned up before session timeout. So SFSBs are already destroyed.

* Application calls session.invalidate()

Need to clean up entire session, including conversations and SFSBs.


So this customized SeamListener would help:


  | import javax.servlet.http.HttpSessionEvent;
  | import org.jboss.seam.servlet.SeamListener;
  | 
  | public class ClusteredJBossSeamListener extends SeamListener {
  |     public void sessionDestroyed(HttpSessionEvent event) {
  |         String threadName = Thread.currentThread().getName();
  |         // Those are application threads, the application calls the session.invalidate() explicitly
  |         if (threadName.startsWith("http-") ||
  |             threadName.startsWith("ajp-")) {
  |             super.sessionDestroyed(event);
  |         } else {
  |             // Don't call ServletLifecycle.endSession(event.getSession()) method, it removes session contents and kills fail over capability
  |         }
  |     }
  | }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4175723#4175723

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4175723



More information about the jboss-dev-forums mailing list