Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Not calling SetComplete in a contained MTS component?

Posted on 2000-02-17
5
248 Views
Last Modified: 2006-11-17
I'm having a design discussion with fellow engineers, and we need a judgment call: We have an MTS component that requires a transaction, and this component instantiates a second MTS component (i.e., composition / containment) through the object context. If the second component never calls SetComplete or SetAbort, but the root component does, will the second component and its resources be freed correctly?

I'd like to see the second, contained component call SetAbort and SetComplete appropriately, but other engineers think this is unnecessary, since all it does is open a connection, call a stored proc, close the connection and return a disconnected recordset.

Which is the better design decision?
0
Comment
Question by:barrett
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:tchalkov
ID: 2533989
Here is what is said in the documentation of MTS:

"If an object doesn't need to maintain its state after it returns from a method call, it should call SetComplete so that it can be automatically deactivated as soon as it returns and its resources can be reclaimed."
0
 
LVL 4

Accepted Solution

by:
wqw earned 200 total points
ID: 2534200
Definately you'll need to call SetComplete/SetAbort.

If your second component is contained completely you can safely omit SetComplete/SetAbort and still have transactions. The problem is that this component will NOT be deactivated after method calls.

You can monitor this behaviour on MTS Explorer Components view. Your component will have N object of which N are activated. The moment you implement SetComplete/SetAbort scheme you get N Objects / 0 Activated.

HTH

</wqw>
0
 

Author Comment

by:barrett
ID: 2538473
MS tells us that the contained object *will* be deactivated. Let me take a few days to test -- our components are all disassembled right now.
0
 
LVL 4

Expert Comment

by:wqw
ID: 2541438
you are obviously using C++ for your components :-))

well, my experience is with VB components and we can't contain nor aggregate in COM sense. we are just instantiating trans components and then call a few methods...

</wqw>
0
 

Author Comment

by:barrett
ID: 2546651
You're right about C++...

MS just sent me this:

Additional information from another engineer:

The short answer is yes the second component will be released properly
although you still need to close and release your resources (i.e.
connections, etc.)

The longer answer is that you should still call SetComplete/SetAbort in the
second component.  All your components, no matter what their purpose should
call one of these two to indicate to the runtime that their state and that
they are done with their work.  This ensures proper behavior in the event
that one day this component becomes a root of a transaction.  It also
expedites the release process.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSIS On fail action 5 38
SQL Pivot with row total 5 27
Add a step to a system backup job 6 18
tools to scan a SQL server's problem 14 26
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question