Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transaction Managment

Status
Not open for further replies.

OlivierPeloux

Programmer
Feb 17, 2003
4
FR
Hi,
I would like to know when COM+ create a new transaction ?
My component A (Business Component) requires Transactions and a Component B (Data Access Component) Support Component.
Is The transaction Created when i open my connexion to the datebase ?
Is the transaction created when i instanciate my Component A ?

An other question ...
My component A can Load, Update, Insert Data and requires transaction.
Do i need to use setAbort or SetComplete when i load Data (when i execute a SELECT SQL Statment) ?

Regards
Olivier
 
Hi oliver

yes the transaction is started when u execute ur business class component.

and you hv to use setcomplete when ur query is complete
that helps transaction manager to know.

anand
 
When Object A is called from the client MTS or Component Services checks if it need a transaction. Since it "Requires a transaction" one is created. Any calls from a connection will have the Resource Manager put a transaction around that transaction. In the case of an ADODB.Connection this means that the .BeginTrans is called and since ADO only supports 1 level of transactions you can not call this method yourself.

When Object A calls Object B there is 2 different behaivors depending on how you instanciate it. If you instanciate it with the following object B does not take part in Object A's transaction and infact has no transaction.

Code:
 DIM tObj as B
 Set tObj = New B
 .
 . 
 .

what happens is that you create the new object and don't allow the transaction to envelop the new object and since it only "Supports a Transaction" MTS won't put a transaction around it.

If you want B to participate in A's transaction then instantiate it in the following manner.

Code:
  Dim tObj as B
  Set B = GetObjectContext.CreateInstance("B")

where B is the full prog ID of the class
GetObjectContext will attempt to create object and pass on itself to the new object thus enveloping the object in A's Transaction.

Not that unless you call DisableComment that the default behaivor of a class is when it is released to call SetComplete if SetAbort or SetComplete was not call. Under component services 1.5 this is changes a bit in syntax but has the same functionality.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top