Web Session Out of Synch with Stateful Session Bean's Session


EJB design: Web Session Out of Synch with Stateful Session Bean's Session

  1. It is common practice to use a Stateful Session bean to manage a business process that requires several steps. For example, the building of a Sales Order.

    If the client of such a bean is a Web application that consists of a series of pages, the web application needs to hold a reference to that bean in the HttpSession object between page invocations. It is possible that the web user browses unrelated pages in the middle of this business process. In that case the stateful session bean may time out before the web session times out.

    What strategy are people using to avoid that bean timeout problem?
    1. Setting bean timeout to a very large number?
    2. Not letting the user navigate to any unrelated pages?

    The downsides of 1, is that we can waste resources. The downside of 2 is that the UI can get a little cumbersome. Is there a better solution?

    Thanks in advance,
  2. If is really very critical application you can think of persisting the session bean in an object or relational database.

  3. Thank you for your suggestion. I'm sure it would work well in some scenarios. We do not really want to persist the steps intermediate steps of the process in the database. This is for performance reasons and because the process we're modelling maps perfectly to a session bean: in other words, it is a process limited only to that user's session.