• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

What would happen if an onMessage method return before commiting a transaction?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would happen if an onMessage method return before commiting a transaction? How about stateless session bean ?

thanks
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for MDB:
the container will log it, rollback the transaction and discard the bean instance

for slsb:
the container will do the 3 things mentioned above plus throw RemoteException or EJBException



 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason is right If you want to go see what the spec exactly mentions, you can go to section 17.6.1:


If a stateless session bean instance starts a transaction in a business method, it must commit the transaction before the business method returns. The Container must detect the case in which a transaction was started, but not completed, in the business method, and handle it as follows:

  • Log this as an application error to alert the system administrator.
  • Roll back the started transaction.
  • Discard the instance of the session bean.
  • Throw the java.rmi.RemoteException to the client if the client is a remote client, or throw the javax.ejb.EJBException if the client is a local client.


  • If a message-driven bean instance starts a transaction in the onMessage method, it must commit the transaction before the onMessage method returns. The Container must detect the case in which a transaction was started, but not completed, in the onMessage method, and handle it as follows:
  • Log this as an application error to alert the system administrator.
  • Roll back the started transaction.
  • Discard the instance of the message-driven bean.

  •  
    Ranch Hand
    Posts: 31
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,

    But what about SFSB as in case of SFSB, if a stateful session bean instance starts a transaction in a business method, it is not must to commit the transaction before the business method returns. Then how does Container detect the case in which a transaction was started but not completed and also what does container do if it detects such case?

    Thanks,
    Mina.
     
    incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
    Devious Experiments for a Truly Passive Greenhouse!
    https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
      Bookmark Topic Watch Topic
    • New Topic