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

Transactions

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I have two questions regarding transactions:

1. When inplementing SessionSynchronization for Sesion Beans, the callback method "beforeCompletion()" is said to run before the end of the transaction -after the business method end- OK.
It is said that in that method you can update the database before end of transaction, but how could I know whether the transaction will commit or rollbact while this methods runs before the end of transaction?
In other words, if I updated the DB and then the transaction rollback then how could I return the old value of the db?

2.I do not understand why Message Driven Beans can use only 2 attributes only (Required or NotSupported)?
more clarification needed for why the other attributes are not needed.

Thank you in advance
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Emad Al-Agouz:


1. When inplementing SessionSynchronization for Sesion Beans, the callback method "beforeCompletion()" is said to run before the end of the transaction -after the business method end- OK.

2.I do not understand why Message Driven Beans can use only 2 attributes only (Required or NotSupported)?



1. Yea, beforeCompletion () will be invoked by the container before the completion of the transaction. That means before either transaction rollback or transaction commit.

I think that, in this method you can do all finalization operation depends up on the status of the transaction. You can get the status of the transaction from userTransaction.getStatus() in BMT and You can use EJBContext.getRollbackOnly() in the case of CMT.


2. MDB have no client view, so rest of the transaction attributes are not meaningful.
 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Emad Al-Agouz:
2.I do not understand why Message Driven Beans can use only 2 attributes only (Required or NotSupported)?
more clarification needed for why the other attributes are not needed.



For MDBs the possible cases are only these two - Either they execute in a transaction context or it is not supported.

RequiresNew, Mandatory, Never, Supports transaction attributes have behaviours which are dependent on if the client is using any existing transaction. Which is not possible for MDBs.

Regards,
Leena
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1. Yea, beforeCompletion () will be invoked by the container before the completion of the transaction. That means before either transaction rollback or transaction commit.



If txn is going to rollback beforeCompletion() wont b called by the container. onli calls this methd if the txn is going to commit.

thanx binoj
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ....

beforeCompletion is for stateful session with CMT only.....so u cannot use UserTransaction here.
This place is your last change to rollback the tx if you want to. So, if you think this tx is not good enough to be allowed to commit, you can do it here.
So I think its much use is going to be for rolllbacking last chance.


but container doesnt calll it if Tx is going to be rollbacked. So its much useful if you want to apply some logic and put Tx to rollback........your last chance as a B P.
 
Straws are for suckers. Now suck on 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