• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Maintaing state in Stateful Session bean

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written Stateful session bean for Shopping application which maintaines the
state of how many items the customer has purchased.
But how do i maintain the state when network or db crashes so I should
recover the state of my stateful session bean for the items purchased

Regards,
Pradeep
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pradeep anandan:
But how do i maintain the state when network or db crashes so I should
recover the state of my stateful session bean for the items purchased


First off, most applications are only as reliable as the underlying datasources. This is especially true of ecommerce applications (is it still cool to call them ecommerce?). If your requirements are 24 X 7 operation, even during database downtime, then you need to address this at the database tier thru clustering the fail-over. It is unrealistic to expect the application to continue to work even when the database is out. If this was the case then why even use a database?
Secondly, a Stateful Session Bean does not store state in the database nor is it dependent on the network so I don't see where you are going with your question.
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris
U r right about the point but if the application server fails can we recover the state of the Stateful session bean till the last succesful transaction.
Regards,
Pradeep
 
Chris Mathews
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by aakash bhatt:
Hi Chris
U r right about the point but if the application server fails can we recover the state of the Stateful session bean till the last succesful transaction.
Regards,
Pradeep


Stateful Session Beans do not live between server restarts. If you need a long-lived object then you will need to use either Entity Beans or just plain DAO (possibly with a Session Bean).
 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris
I think in Websphere u can write the state of Session into a file and if Application server restarts
the Session bean automatically checks the state and continues from there.
Regards,
aakash
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aakash,
But does it make any sense even if the session bean is recreated, the customer in most likelyhood of the cases would have destroyed the session after the failure of the application Server.
Am I missing some point?
Thanks,
Pradeep
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by aakash bhatt:
Hi Chris
I think in Websphere u can write the state of Session into a file and if Application server restarts
the Session bean automatically checks the state and continues from there.
Regards,
aakash


Are you talking about passivating your session bean into streams in a file system? Find the details on any EJB book. This should be available for J2EE and not just WeBSphere.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic