>NET的分布式处理

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 2006-03-20 09:53  Macou  阅读(216)  评论(0编辑  收藏  举报

导航