欢迎光临
我们一直在努力

Distributed Transactions-ASP教程,ASP应用

建站超值云服务器,限时71元/月

(转自saucer)

在企业开发里,经常遇到的一个问题是需要做distributed transactions。一般推荐的做法是做成servicedcomponent,参考

transaction control

writing serviced components

这种做法有几个问题,该组件以及所依赖组件必须是strong-named的,在通常的情形下(譬如web application里),我们需要手动注册组件。但这样,如果我们改动组件的话,需要停止服务,注销组件,然后重新注册组件。另外,这transaction是declarative和automatic的,无法用编码精确控制 transaction,而且declaration是在类的级别上的,无法在方法层次做 transaction。其原因是,servicedcomponent是基于早期com+的服务架构之上的,transactional context是与object(对象)密切结合在一起的。

但在几年前随xp推出的com+ 1.5 (windows 2003服务器也有支持)里, transactional context可以独立于object(对象)之外,极大地简化了transactional programming。下面这篇2002年msdn杂志上由com+专家tim ewald介绍了相关的api (coenterservicedomain/coleaveservicedomain),并且提供了c# wrapper 。

discover powerful low-level programming in windows xp with new com+ apis

在.net 1.1里,同样的功能是由2个类,system.enterpriseservices.servicedomain与system.enterpriseservices.serviceconfig,来实现的。

这里是don box去年7月12日的blog里的例子,

serviceconfig config = newserviceconfig();

config.transaction = transactionoption.required;

servicedomain.enter(config);

mytxcode();

servicedomain.leave();

在.net 2.0里,根据don,你可以这么做

using (transactionscope scope = newtransactionscope())

{

mytxcode();

scope.consistent = true;

}

也请参考

using distributed transactions in .net 1.x without deriving from servicedcomponent

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Distributed Transactions-ASP教程,ASP应用
分享到: 更多 (0)