Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Open transaction in SLSB/MDB

 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A stateless session/message-driven bean has to complete the transaction, before the method ends. What happens if the transaction is kept open?...
Will there be an exception and what happens to the open transaction?
RemoteException/EJBException for remote/local clients?
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vish,
As the container must ensure that rule, I guess that it will throw some system exception in case your bean doesn't conform to it. Which one, I don't know (but I'd like to BTW ).
Now if a system exception is well thrown, another rule will be applied anyway : the open transaction will be rollbacked.
Regards,
Phil.
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Phillipe is right -- if the stateLESS bean or MDB starts but does not complete a transaction in a business method, the Container will:
* Log it as an error
* roll back the transaction
* discard the bean instance
* For STATELESS beans -- throw RemoteException or EJBException depending on whether the client is remote or local
* For MessageDrive beans -- no exception is thrown, of course, because there's no client to get it!
So, the only difference between MDBs and SLSBs in this case, is that the Container won't thrown an exception with a MDB, but in both cases, the bean is destroyed, the transaction rolled back, and the problem is logged.
cheers,
Kathy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic