gpt4 book ai didi

transactions - MSDTC 事务超时问题

转载 作者:行者123 更新时间:2023-12-04 05:23:24 26 4
gpt4 key购买 nike

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

任何引用将不胜感激,提前致谢。

最佳答案

我叫 Tony,我在 Microsoft 支持的分布式事务团队工作。我已阅读您的帖子,相信我了解您的要求。这是我为在组件级别进行更改而编写的代码示例。希望对您有所帮助:

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

关于transactions - MSDTC 事务超时问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7563743/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com