从.NET Framework 4.6.1开始 it's possible to have distributed transactions in SQL Azure。现在,我尝试使用SOA构建一个概念验证,因此我尝试创建一个TransactionScope并调用连接到单个SQL Azure数据库的几个WCF服务,但我&#39 ; m失败了。
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }))
{
DOConfigurationServiceClient proxy = new DOConfigurationServiceClient();
proxy.CreateAccessByAccount(accessByAccount);
scope.Complete();
}
我收到带有此消息的System.ServiceModel.ProtocolException:
There is a promotable enlistment for the transaction which has a PromoterType value that is not recognized by System.Transactions. 1c742caf-6680-40ea-9c26-6b6846079764
这是堆栈跟踪
at System.Transactions.InternalTransaction.ThrowIfPromoterTypeIsNotMSDTC()
at System.Transactions.Transaction.Promote()
at System.Transactions.TransactionInterop.ConvertToOletxTransaction(Transaction transaction)
at System.Transactions.TransactionInterop.GetTransmitterPropagationToken(Transaction transaction)
at System.ServiceModel.Transactions.WsatTransactionFormatter.WriteTransaction(Transaction transaction, Message message)
at System.ServiceModel.Channels.TransactionChannel`1.WriteTransactionToMessage(Message message, TransactionFlowOption txFlowOption)
是否可以在连接到SQL Azure数据库的WCF服务之间建立分布式事务?
关于它的文档太少或没有,所以任何帮助都将受到高度赞赏。
答案 0 :(得分:3)
简短回答,这不是SQL Azure上支持的方案。
WCF中跨多个服务调用的事务流动依赖于使用分布式事务处理协调器(MSDTC)样式事务。 SQL Azure不支持这些(没有连接到SQL Azure的MSDTC)。
新的SQL Azure弹性事务由SQL本身管理,而不是由外部事务协调器管理。
一种可能的替代方法是创建一个服务方法,该方法执行您要在事务中封装的所有操作,并在该服务方法的范围内启动(和完成)事务。