• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Choose Type Of Transaction with EJB (CMT VS BMT)

 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for all answer.
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic