Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Not calling SetComplete in a contained MTS component?

Posted on 2000-02-17
5
Medium Priority
?
266 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
[X]
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
  • 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 800 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

618 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