Plunging into .NET Development

Weblog Pieter Gheysens
Microsoft .NET Development - C# - Enterprise Library - Visual Studio 2005 Team System - Compuware DevPartner - ...
 


Wednesday, May 31

COM+ Transactions - Time-out

After implementing a transaction for a specific method in our application, we were unexpectedly faced with a Transaction rolled back error. At the beginning, we really had no clue what was the cause of this because the transaction sometimes completed successfully on other computers for the same environment and for the same action we started.

After some research and thinking, we concluded that it had probably something to do with a time-out. The default time-out for a transaction is set to 60 seconds. It must have been that our transaction finished just before those 60 seconds on one computer while it wasn't completed yet on another computer in that timeframe. These kind of errors are often hard to find and reproduce, but luckily it was easy to solve and to avoid our Transaction rolled back error.

Also while debugging in a development environment, a transaction may time-out before it is committed or aborted (due to breakpoints and waiting times). To avoid a time-out, you must use a time-out property on the transaction attribute and choose a time-out (in seconds) according to your specific needs ...

  [Transaction(TransactionOption.Required, Timeout=120)]

You can also set this manually on the component in Component Services (Transactions Tab), but I prefer to set this as a property in code. When your assembly gets registered in COM+, everything is automatically done for you and you (or most of the time some other dude) won't change by any chance the default time-out for all COM+ applications on the server because there's also a global transaction time-out. You don't wish this to happen when there are other components registered in COM+ on that server, especially if you are decreasing the time-out value!



It's also good practice to limit the time a transaction takes in code. I mean that you should start a transaction as late as possible and stop it as soon as possible.

1 Comments:

  • At 11:43 AM, Anonymous Anonymous said…

    HI
    I am facing the same problem with the COM+ components and I need to set the transaction timout of the ComponentServices/Computers/MyComputer from code so that it will be remembered for all the components. Did you find any code that do that?
    If yes pleas share it with me because I did not find any.
    Thanks
    Dragos
    stefanescu.dragos@yahoo.com

     

Post a Comment

<< Home