InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Understanding Seam Nested Conversations and Timeouts

Posted by Bryan Clauser on Jan 16, 2008

Sections
Development
Topics
Java ,
Web Frameworks
Tags
JBoss Seam

State management has always been a challenge for web application developers. Handling interactions at an application level instead of a request level is what conversations manage. Jacob Orshalick discusses Seam's conversation model with an explanation of how nested conversations work with Seam's demo booking example, a hotel booking application.

Seam's conversation model provides a simplified approach to continuations. If you are familiar with the concept of a continuation server you are aware of the capabilities they provide including seamless back-buttoning and automatic state management. A user session has many continuations that are simply snapshots of state during execution and the continuations can be reverted to at any time. If you are not familiar with this concept, not to worry, Seam makes it simple.

This is just part of the model, Seam also allows the conversation nesting:

Nesting a conversation provides a state container that is stacked on the state container of the original or outer conversation. Any objects that are set into the nested conversation's state container do not affect the objects accessible in the parent conversation's state container. This allows each nested conversation to maintain its own unique state.

Orshalick goes through the ways to define a nested conversation as well as make sure it has properly cleaned up. An example of extending the Seam booking example using JBoss Developer Studio concludes a descriptive example of nested conversations.

Nested conversations isn't the only thing that Jacob Orshalick has been clearing the air about with Seam, he has also discussed the topic of conversation timeouts:

Conversation timeout seems to be a commonly misunderstood Seam concept. I often see postings on the Seam forums claiming that the conversation-timeout doesn't work! Well, actually it does, you simply have to understand the semantics.

Using same examples as with nested conversations, Orshalick shows that when dealing with multiple conversations only the background conversation is affected by the conversation timeout. With this being said, the foreground conversation would timeout when the session itself times out.

Orshalick's concluding thoughts:

Seam offers a very attractive approach to state management through its simple conversation model. Complicated issues developers struggled with in the past including multi-window operation and back-buttoning are handled seamlessly.
Spring Web Flow by Steven Devijver Posted
Re: Spring Web Flow by Mike Heath Posted
Re: Spring Web Flow by Steven Devijver Posted
Re: Spring Web Flow by Keith Donald Posted
Re: Spring Web Flow by Jacob Orshalick Posted
Re: Spring Web Flow by Frank Janes Posted
  1. Back to top

    Spring Web Flow

    by Steven Devijver

    Complicated issues developers struggled with in the past including multi-window operation and back-buttoning are handled seamlessly.


    Which were already solved seamlessly by Spring Web Flow back in 2005.

  2. Back to top

    Re: Spring Web Flow

    by Mike Heath

    If only Spring Web Flow had the extended JPA persistence context that comes with Seam conversations. Sure Spring Web Flow is nice but it only solves half the problem if you're using JPA.

  3. Back to top

    Re: Spring Web Flow

    by Frank Janes

    Ignorant Springer, XML abuser.

  4. Back to top

    Re: Spring Web Flow

    by Steven Devijver

    If only Spring Web Flow had the extended JPA persistence context that comes with Seam conversations. Sure Spring Web Flow is nice but it only solves half the problem if you're using JPA.


    I wouldn't call "the extended JPA persistence context" a solution. Just because you don't get LazyLoadingExceptions anymore does not mean you've solved a problem.

  5. Back to top

    Re: Spring Web Flow

    by Keith Donald

    Mike,

    Spring Web Flow 2.0 ships two "flow execution listeners", one that uses Hibernate APIs and another that uses JPA, for managing extended flow-scoped persistence contexts. The context is automatically allocated for you when a new flow execution begins, disconnected when it pauses, rebound to the current thread when it resumes, and closed when it ends (committing any changes in a transaction if the end state reached was a 'commit' state). This can provide an automated way to apply changes to managed entities over a series of requests, and flush those changes when you're done editing (on save or confirm, for example).

    Keith
    Technical Lead, Spring Web Flow

  6. Back to top

    Re: Spring Web Flow

    by Jacob Orshalick

    Bryan, thanks for quoting my articles, it is great to see them on InfoQ. I apologize for a late response, but things have been very busy.

    In regards to Spring Web Flow, I believe it is also an excellent alternative for conversation management. I've also been very interested in the direct support for continuations it provides. I used Spring Web Flow in its early stages a few years ago, so it is great to see it progressing.

    @Steven: I am curious as to how you would propose solving the LIE issue. Through usage of Seam-managed Transactions and an SMPC you have a very clean model to avoid these issues altogether without having to resort to the Open Session in View pattern. This allows you to scope a PersistenceContext to a conversation and keep transaction demarcation where it belongs in the request lifecycle. Please let us know if you have a better solution.

    Jacob

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.