At 10:15 AM 1/31/00 +0100, you wrote:
 > Paolo De Lutiis wrote:
 > >
 > > Hi,
 > >
 > > I'm trying to balance my web application among different JServ but I
 > > found the following problem:
 > > when one JVM crushes (caused by SW/HW failure) my clients loose their
 > > sessions.
 > > I'd like to know if there are standard methods to overcome this problem,
 > > for example keeping
 > > the httpsession objects in a rmi server heap, or dbms ( or like).
 > > Any ideas ? Any examples ?
 > >
 > > Thanx
 > >
 > No way. You'll have to code it, not difficult IMO, but "application
 > dependant" : what do you save ? what about transactions ? etc ...
 >
 > Jean-Luc

I put together something like this.  Here's how it went:

* Add stuff to JServServletManager to manage a config parameter for a 
"save-session-path".
* In JServServletManager.init() create and start a thread that will 
periodically save "dirty" sessions to disk.
* In removeSession(), make sure you delete the saved file, if it exists.
* Modify JServSession to add variables to track the save-path (if any), and 
a "dirty" flag that tracks un-saved changes.
* In JServSession.putValue() and removeValue(), set dirty=true.
* Also in JServSession, add some methods to write the session object to a 
specified file.  You can do this via writeObject() to an 
ObjectOutputStream.  The filename is constructed using a directory path and 
the session ID.
* In JServConnection.getSession(),  add code to the effect that if a 
session ID was specified by the client, but the session is not in-memory, 
look for it on disk and if found, create a new session object and re-load 
it from the file.  Delete the file after you finish.
* If you stash any beans/etc as session values, make sure they implement 
Serializable.

That's the summary.  Stashing to file is easy to do, but you could use a DB 
if you really wanted to.  With either approach, you need a resource (either 
shared file path or DB server) that has high assurance of always being 
available.

- Fernando


=======================================
Fernando Salazar <[EMAIL PROTECTED]>
w -781-392-2514


--
----------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to