• Post Reply Bookmark Topic Watch Topic
  • New Topic

Stateful - transaction commit in CMT (Doubt)

 
Veena Sundaram
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that Container will call afterCompletion(boolean) when it has committed or rolled back the transaction. Can anyone let me know when does the container decide to commit the transaction in the Stateful session bean, which uses CMT.

For example, I (Bean developer) might want to start the transaction when he logs in a auction site and commit when he logs out. How does the container decide to commit the transaction - hopefully it is not at the end of the method. Is there anything that the bean developer needs to do on this. Can anyone get back to me on this.
 
Vinay Raj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The functionality that you have mentioned requires a long running transaction. EJBs are to be used only in short running transactions i.e. transactions spanning seconds if not millisecs.

The functionality you mentioned is typically achieved by storing the shopping cart state in-memory and committing only on the final checkout or payment. The other option is to commit each and every user action. Commit activity information on login or when the user adds an item in his shopping cart etc.

I hope this answers your question.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!