tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ronald Klop <ronald-mailingl...@base.nl>
Subject Re: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster
Date Fri, 18 Apr 2008 12:06:37 GMT
Yes, I know how to work around the problem. But I don't like workarounds. All implementations
I can think of are very fragile. What if somebody stops my Tomcat with kill one day?

My session isn't destroyed, so I don't understand why the event is thrown.

Ronald.

On Thu Apr 17 15:49:49 CEST 2008 Tomcat Users List <users@tomcat.apache.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Ronald,
> 
> Ronald Klop wrote:
> | In sessionDestroyed I register the user as logged out.
> |
> | How can I know if sessionDestroyed is called from session.invalidate()
> | from the real expiration of the session or shutdown of one cluster node?
> 
> Are your shutdowns typically planned? If so, you could stick something
> in the session like "shuttingDown192.168.1.123" and then check for that
> key when you are processing a "session destroyed" event. Just ignore
> such events from the current machine's IP address.
> 
> Or, you could even do something like this:
> 
> 1. Before shutdown, place a "shutting down" key in the application scope.
> 
> 2. Modify your sessionDestroyed code to do this:
> 
> public void sessionDestroyed(HttpSessionEvent se)
> {
> ~ ServletContext application = se.getSession().getServletContext();
> 
> ~ if(null != application.getAttribute("SHUTTING_DOWN"))
> ~ return;
> 
> ~ // Otherwise, process the shutdown normally.
> }
> 
> This should work given that the application scope is not distributed
> across nodes in the cluster. You just put your node in a "shutdown"
> state and then ignore all events (or any you care to ignore).
> 
> Hope that helps,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iEYEARECAAYFAkgHVX0ACgkQ9CaO5/Lv0PC27ACfdh2El6QLeI4LpHaoowJcfJ/Q
> cOgAn1ocNzI8qXhax4cs/LLUJYSqWytT
> =7EAa
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message