rex的博客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
COM+1.5中有一套新的 API:SWC(Services without Components).而.NET1.x也对其进行了封装。在reference中加system.enterprise.dll,可以看到在System.EnterpriseSerivce命名空间中有ServiceConfig,ServiceDomain类,可以用它们来进行分布式事务处理:
        ServiceConfig cfg=new ServiceConfig();
        cfg.Transaction=TransactionOption.Required;
        ServiceDomain.Enter(cfg);
        ...
        ...
        //在这里操作不同数据库
        ...
        ...
        ServiceDomain.Leave();
 事务的规则和COM+一样。事务最终是否提交可以在代码中用ContextUtil的SetAbort()和SetComplete()方法控制。这样的好处是不再需要从ServicedComponent继承,可用作轻量级的分布式处理。
posted on 2005-12-16 15:07  rex  阅读(1006)  评论(0编辑  收藏  举报