开发者

MSDTC transaction timeout issue

I'm facing a MSDTC transaction timeout issue now. For historical reaso开发者_开发知识库n, we still have lots of legacy code running DB operations by C++ ODBC, and the connection is escalated into MSDTC by default. The issue is when I try to perform a lengthy operation which takes longer than 1 minute, the transaction will be disposed by MSDTC automatically, I found that it's possible to change this value by Component Services administrative tool, However can I set this timeout value programmatically?

Any reference will be appreciated, thanks in advance.


My name is Tony and I work with the Distributed Transaction Team here at Microsoft Support. I have read your post and believe I understand what you're asking for. Here's a code sample I wrote to make the change at the component level. I hope this helps you:

//Connect to the machine
COMAdmin.COMAdminCatalog m_objAdmin1 = new COMAdmin.COMAdminCatalog();
m_objAdmin1.Connect(System.Environment.MachineName.ToString());

//Get a list of COM+ Applications
COMAdmin.COMAdminCatalogCollection objApplications = (COMAdmin.COMAdminCatalogCollection)m_objAdmin1.GetCollection("Applications");
objApplications.Populate();
COMAdmin.COMAdminCatalogObject appToFind = null;

//Find the application you want to change
for (int i = 0; i < objApplications.Count; i++)
{
    appToFind = (COMAdmin.COMAdminCatalogObject)objApplications.get_Item(i);

    if (appToFind.Name.ToString() == "MSTEST")
    {
        break;
    }
}


 //Now find the component in the application you wish to change
COMAdmin.COMAdminCatalogCollection objComponents = (COMAdmin.COMAdminCatalogCollection)objApplications.GetCollection("Components", appToFind.Key);
objComponents.Populate();
COMAdmin.COMAdminCatalogObject ComponentsToFind = null;

for (int i = 0; i < objComponents.Count; i++)
{
    ComponentsToFind = (COMAdmin.COMAdminCatalogObject)objComponents.get_Item(i);

    if (ComponentsToFind.Name.ToString() == "tdevere_vb6_com.Tdevere")
    {
        break;
    }
}

//Set the Transaction support option
//Enable the overide option
//Set the new value for the time out option
COMAdmin.COMAdminTransactionOptions temp = (COMAdmin.COMAdminTransactionOptions )ComponentsToFind.get_Value("Transaction");
ComponentsToFind.set_Value("Transaction", COMAdmin.COMAdminTransactionOptions.COMAdminTransactionRequiresNew);
ComponentsToFind.set_Value("ComponentTransactionTimeout", 120);
ComponentsToFind.set_Value("ComponentTransactionTimeoutEnabled", true);

//Make sure to save the changes
objComponents.SaveChanges();
objApplications.SaveChanges();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜