MSDTC事务超时问题



我现在面临一个MSDTC事务超时问题。由于历史原因,我们仍然有许多遗留代码通过c++ ODBC运行DB操作,并且默认情况下连接升级为MSDTC。问题是,当我尝试执行耗时超过1分钟的冗长操作时,事务将由MSDTC自动处置,我发现可以通过组件服务管理工具更改此值。但是,我可以以编程方式设置此超时值吗?

我的名字是Tony,我在微软支持的分布式事务团队工作。我读了你的帖子,相信我明白你的要求。下面是我编写的代码示例,用于在组件级别进行更改。我希望这对你有所帮助:

//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();

相关内容

  • 没有找到相关文章

最新更新