Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Choose Type Of Transaction with EJB (CMT VS BMT)

 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i'm develope Application , it's use EJB and have transaction management.

So, Which i should BMT or CMT to manage transaction in my application ???
 
Ranch Hand
Posts: 8943
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CMT is always recommended.
You will use BMT when

1. You need to start multiple transactions within a single method.
2. You need your transaction to span mutilple methods.

Point 1 can be easily avoided by writing a method for each transaction.
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The comparison you are asking is about: managing transactions by yourself (BMP) and managing transactions with container help (at least, CMP).
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In old days, when we still use EJB 1.x, as the containers are suck, we use BMP to control the transactions.

Nowadays, less and less people use BMP as the containers become more and more powerful, and EJB 2.0 even specified that, Entity bean can only use CMP!

Nick
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most important is you should know what you can do.

Message Driven Bean - CMT or BMT
Session Bean - CMT or BMT
Entity Bean - CMT only.

BMT - You have to Code
CMT - You can control through Deploy Descriptor attributes.

For CMT, Message Driven Bean can use only NotSupported and Requried.

BMT transactions are one way. They can propogate out to a CMT bean, but no other transaction can propogate into a BMT bean.

Th advantage inn BMT I see is that you can reduce the scope of a transaction.

Having said this, I would prefer CMT, unless there is something that I cannot do with CMT, but can do with BMT.

Peter.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for all answer.
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In some cases the only option is to use BMT.

Eg, with CMT Message Driven Bean message acknowledgment depends on whether the transaction rollbacked / committed. That is what spec's section "15.4.8 Message acknowledgment" says


Message-driven beans should not attempt to use the JMS API for message acknowledgment. Message acknowledgment is automatically handled by the container. If the message-driven bean uses container managed transaction demarcation, message acknowledgment is handled automatically as a part of the transaction commit. If bean managed transaction demarcation is used, the message receipt cannot be part of the bean-managed transaction, and, in this case, the receipt is acknowledged by the container.



Therefore, if MDB needs to acknowledge the message and rollback the transaction at the same time then the only way to do it is to use BMT.


[ July 22, 2004: Message edited by: Alex Sharkoff ]
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic