• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

CMT or BMT ?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a question with regards to the usage of CMT and BMT in terms of managing transactions in the web application. I have always felt CMT is safer to use and less work so always would choose CMT in my applications.

Are there any drawbacks in using CMT? In what situations one would choose BMT over CMT?

Thanks
Shanika Dias
 
author
Posts: 84
5
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shanika,

You are correct in saying that CMTs are safer and easier to use. They are the preferred way of handling transactions. BMTs are useful for complex transactions and rollback situations. They provide a means to more carefully control the transaction boundaries, that is, when the transaction starts and ends. With CMTs the transactions are bounded by the method. BMTs allow you to specify exactly when and where it ends.

The chief drawback to CMTs in my mind is that the entire method is part of the transaction. If this method is lengthy, then you may be spending more time in the transaction than is needed. This can tie up resources needlessly. Restructuring your code can reduce the time spent in the method.

I would use BMTs where the transaction logic is not handled adequately by CMTs. This can occur when the start and stop of a transaction is not simply at the beginning and end of a method.
 
Shanika Dias
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Richard.

In that case is it possible to have a mix of CMT and BMT in an application, so that for complex, long methods to use BMT and the rest to have CMT?

 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shanika Dias wrote:

In that case is it possible to have a mix of CMT and BMT in an application, so that for complex, long methods to use BMT and the rest to have CMT?



That's possible. Transaction management typically is per component level. i.e. if you applications has multiple components (like EJBs) then each component (i.e. each EJB for example) can have a different transaction management characteristic. One bean can be configured for BMT and the other can use CMT.

 
Shanika Dias
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jaikiran. It's very clear now.
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic