ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

.net 事务超时时间设置

2019-12-10 10:53:07  阅读:302  来源: 互联网

标签:事务 transaction transactions System machine timeout net 超时 config


写了一段程序,使用.net framework里的事务,设置了超时时间为30分钟,但是奇怪的是在10分钟的时候就报错了。搜索了一下,原来还需要修改machine.config(默认应该在C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG中),比如设置为30分钟:

<configuration>
 <system.transactions>
  <defaultSettings timeout="00:30:00" />
 </system.transactions>
</configuration>

 

需要注意的是,system.transactions应该放在configSections节点之后,否则程序启动时会报“无法识别的配置节 system.transactions”。

 

引用原文:


This came up a couple of times recently, so I am posting it more broadly. Courtesy of Mike Clark and Jim Carley. 

System.Transactions has two timeout values that you can specify in configuration files. 

The default timeout for System.Transactions transactions is 1 minute.  You can set it in either app config, web config, or machine config.  (You can also set the timeout for a particular transaction programmatically within the application, by using one of the appropriate constructors forTransactionScope or CommittableTransaction).  Setting the default timeout to 30 seconds in config code looks like the following.

<configuration>
 <system.transactions>
  <defaultSettings timeout="00:30:00" />
 </system.transactions>
</configuration>

For System.Transactions there is also a maximum transaction timeout. It is designed to be used by the System Administrator to limit transaction timeouts. If this setting is not specified, it defaults to 10 minutes.  It cannot be overridden in code.   If the app.config timeout or the timeout specified in the constructors above exceed the maximum timeout in the machine.config, the timeout is adjusted down to the maximum timeout value. That can be specified only in machine config.  To change that you would specify the maxTimeout property of the machine settings section.  For example, this specifies 30 seconds:

<configuration>
 <system.transactions>
   <machineSettings maxTimeout="00:30:00" />
 </system.transactions>
</configuration>

So, for example if your app.config setting specifies a defaultSettings timeout of zero, which implies (with a screwy sort of logic) infinite timeout, or if your application code specifies a zero timeout in one of the constructors, then the actual timeout of the transaction will not be infinite - it will be bound to the setting for machineSettings maxTimeout. 

For any high-throughput transactional server, The default maxTimeout setting is probably not right for you.  You're going to want to set this pretty low. 

This is for any transaction managed by DTC - that would include transactions involving SQL Server, Oracle, MQ, DB2, and so on.  If your transactions are timing out after 10 minutes and you want to know why, check these settings. 


———————————————— 
原文链接:https://blog.csdn.net/lazyleland/article/details/7988622

标签:事务,transaction,transactions,System,machine,timeout,net,超时,config
来源: https://www.cnblogs.com/yexiaoyanzi/p/12015291.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有