Behavior_WCF事务

2PC 2阶段提交

实现

1.在服务契约指定协议需要会话绑定(要求所选binding需支持会话) 

[ServiceContract(SessionMode = SessionMode.Required)]

2.操作契约上指定该操作可以作为事务流的一部分

[TransactionFlow(TransactionFlowOption.Allowed)]

3.方法实现需要指定该方法纳入事务TransactionScope事务范围

[OperationBehavior(TransactionScopeRequired = true)]

4.配置文件开启事务<binding name="wsHttpBinding" transactionFlow="true"></binding>

  

MSDTC Microsoft Distributed Transaction Coordinator 分布式事务协调器

posted @ 2020-02-06 20:23  vvf  阅读(89)  评论(0编辑  收藏  举报