Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session behavior in distributed environment

 
Calvin Kong
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a question regarding session behavior in distributed environment. Say I have 2 servers in clusters. If inside the servlet, the application call session.invalidate() method right after the session is move from server A to server B, what will happen? Also, any session attribute that's not implementing java.io.Serializable will not be migrated. Does it mean I'll get null value if I call session.getAttribute("XXX") when the session is moved to server B where the attribute is set when the session is in server A? Does the behavior depend on server? (we are using JRun)

Thanks

Calvin

[ January 21, 2005: Message edited by: Calvin Kong ]
[ January 21, 2005: Message edited by: Calvin Kong ]
 
sawan parihar
Ranch Hand
Posts: 250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the application call session.invalidate() method right after the

The session will be invalidated and that session object is ready for GC.

Also, any session attribute that's not implementing java.io.Serializable will not be migrated

It depends upon the container implementation. If the attribute it not serialized you will get null after the migration of session. Actually some container may throw error if attribute is not serialized(but i am not very sure about it). Lets wait for the reply from other guys.

Hope that helps.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Calvin Kong:
If inside the servlet, the application call session.invalidate() method right after the session is move from server A to server B, what will happen?

Assuming you are using session replication, the session will be invalidated in both places. If you are planning to allow the session to move between servers, you should be using replication. (Otherwise you could get inconsistent results.)

Also, any session attribute that's not implementing java.io.Serializable will not be migrated. Does it mean I'll get null value if I call session.getAttribute("XXX") when the session is moved to server B where the attribute is set when the session is in server A? Does the behavior depend on server? (we are using JRun)

Yes, it depends on the server. WebSphere logs an exception and then places null in the session.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic