什么是在调用WCFado.net数据服务的工作流服务中实现事务的最佳方法 [英] whats the best way to implement transactions in workflow services calling WCFado.net data services

查看:60
本文介绍了什么是在调用WCFado.net数据服务的工作流服务中实现事务的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作流服务,该服务通过代码自定义活动来调用ado.net数据服务.
我想在单个事务中执行两个数据库操作(贷记和借记).如何执行此交易.客户端是asp.net Web应用程序.我想到了使用此链接

I have a Workflow service which is calling ado.net data service through code custom activity.
I want to perform two database operations ( credit and debit) in a single transaction. How to implement this transaction. the client is asp.net web application. I thought of flowing transactions from client to workflow services using this link http://msmvps.com/blogs/theproblemsolver/archive/2009/12/21/flowing-transaction-into-a-workflow-using-wf4.aspx  but my doubt it will it rollback ado.net data service operation also in case if transaction faiils.

预先感谢
suchi

Thanks in advance
suchi

推荐答案

根据您的方案,您有两种选择.我假设您希望事务在您的工作流服务中启动,并且不会从其他地方流出.

选项1)使用TransactedReceiveScope,并将事务生存期与工作流中的某些现有服务调用绑定.

您没有事务的工作流服务(想象其中的每一行都是一个序列中的工作流活动):
ReceiveFoo
DoWork(贷记/借记等) )
SendReplyFoo(可选,假设您正在使用双向服务合同)

Your Workflow Service without transactions (imagine each one of these lines is a workflow activity in a sequence):
ReceiveFoo
DoWork (Credit/Debit, etc...)
SendReplyFoo (optional, assumes you are using two-way service contracts)

您的带有事务的工作流服务:
TransactedReceiveScope
   要求= ReceiveFoo
  正文= DoWork(信用/借记等,SendReplyFoo(可选))

Your Workflow Service with transactions:
TransactedReceiveScope
    Request = ReceiveFoo
    Body = DoWork (Credit/Debit, etc..., SendReplyFoo(optional) )

在这种情况下,将在接收到请求后创建一个事务,并且该事务将在TransactedReceiveScope正文的整个持续时间内处于环境状态.

选项2)如果不这样做,请使用TransactionScope.不一定要将您的事务生命周期限制在现有服务调用范围内.

In this case, a transaction will be created after receiving the request and the transaction will be ambient for the duration of the TransactedReceiveScope's body.

Option 2) Use TransactionScope if you don't necessarily want to scope your transaction lifetime to an existing service invocation.

没有事务的工作流服务:
ReceiveFoo
SendReplyFoo(可选,假设您正在使用双向服务合同)
DoSomeStuff
DoWork(贷方/借方)
DoSomeOtherStuff

Your Workflow Service without transactions:
ReceiveFoo
SendReplyFoo (optional, assumes you are using two-way service contracts)
DoSomeStuff
DoWork (Credit/Debit)
DoSomeOtherStuff

您的带有事务的工作流服务:
ReceiveFoo
SendReplyFoo(可选,假定您正在使用双向服务合同)
DoSomeStuff
TransactionScope
    DoWork(贷方/借方)
DoSomeOtherStuff

Your Workflow Service with transactions:
ReceiveFoo
SendReplyFoo (optional, assumes you are using two-way service contracts)
DoSomeStuff
TransactionScope
    DoWork (Credit/Debit)
DoSomeOtherStuff

对于大多数情况,我会建议选项1 .在这两种情况下,贷方和借方活动都将在同一环境交易中执行.我不熟悉如何调用ADO.NET数据服务,但是我假设只要您在环境事务下进行操作,它就会流入这些服务.

I would recomment Option 1 for most scenarios. In both cases, both Credit and Debit activities will execute under the same ambient transaction. I'm not familiar with how you invoke ADO.NET data services, but I assume as long as you do so under an ambient transaction it will flow to those services.

这是回答您的问题还是我误解了情况?

Does this answer your question or did I misunderstand the scenario?

-Clark


这篇关于什么是在调用WCFado.net数据服务的工作流服务中实现事务的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆