By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 1,904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

Distributed transaction help

P: n/a
I have 2 services, ServiceA and ServiceB. Certain user driven functions
require ServiceA to perform some DB tasks, before sending a request to
ServiceB to perform some additional tasks. If ServiceB fails to execute the
request, I would like ServiceA to rollback its changes. ServiceA and ServiceB
are located on 2 different servers on the same network.

I am struggling to find resources that cover this scenario. most articles
that discuss distributed transactions cover the scenario where 1 service
needs to update multiple data sources within a transaction.

Does anyone have any experience of handling this scenario? If so, could you
throw me a few pointers or any links you may have that can help.

Thanks
Dan
Jul 26 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Dan,

This scenario is very much specific to what the 2 services are doing. From
my understanding of the problem, You could club the service a and service b
into a single service say service C, i.e the funstionality that is
implemented by service b should be implemented by a remote transactional
component within service A itself. This is because normally a service is
used when you woudl like to manage the triggering of the functionality, but
in this case the service b is triggered by service A (sort of)

The architecture and business objects that the service controller internally
uses and calls, should be made to handle transactional calls. The
transcations could be handled at the data layer or alternatively the
transaction object coudl be passed.

Hope the above gives you some guidance.

Hitesh Ramchandani.

"Dan Kelley" <Da*******@discussions.microsoft.comwrote in message
news:0F**********************************@microsof t.com...
>I have 2 services, ServiceA and ServiceB. Certain user driven functions
require ServiceA to perform some DB tasks, before sending a request to
ServiceB to perform some additional tasks. If ServiceB fails to execute
the
request, I would like ServiceA to rollback its changes. ServiceA and
ServiceB
are located on 2 different servers on the same network.

I am struggling to find resources that cover this scenario. most articles
that discuss distributed transactions cover the scenario where 1 service
needs to update multiple data sources within a transaction.

Does anyone have any experience of handling this scenario? If so, could
you
throw me a few pointers or any links you may have that can help.

Thanks
Dan

Jul 26 '06 #2

P: n/a
Hello Dan,

why you don't create a custom compensator that you can incorporate in
your transactions of ServiceA? By using this, if a task/process in
ServiceB fails, it aborts the transaction that contains the serviceB
task (this is ServiceA).

Check the following links...

http://msdn2.microsoft.com/en-us/library/8xkdw05k.aspx

There is another way (probably easier) involving COM+ .

Let's say ServiceA has a method MethodA and ServiceB has a method
MethodB ... with code similar to the following you can achieve the same
functionality...

public void MethodA() {
try {
int result = serviceB.MethodB();
if (result<0){
ContextUtil.SetAbort();
}
else{
ContextUtil.SetComplete();
}
}
catch (Exception eX) {
ContextUtil.SetAbort();
}
}

This requiers ServiceA and ServiceB to be COM+ component in order to
take advandage of the provided COM+ services and marked as
Transaction.Support/Required (it depends on how you invoke the
methods).

So, when MethodA is executed a transaction begins. Inside that
transaction you call methodB which will be enlisted in the current
transaction. From inside methodB you can call ContextUtil.SetAbort() to
mark the transaction as failed, but you can also mark the transaction
as failed from MethodA (depending probably on the MethodB result). In
that way, when the method completes (and depending on the ContextUtil
votes, the transaction will either be commited, or rollbacked).

By using COM+ you have great flexibility regarding the
deployment/configuration of your application, so the distributed part
should not pose a serious issue.

I hope it helped

Regards
Tasos

Dan Kelley wrote:
I have 2 services, ServiceA and ServiceB. Certain user driven functions
require ServiceA to perform some DB tasks, before sending a request to
ServiceB to perform some additional tasks. If ServiceB fails to execute the
request, I would like ServiceA to rollback its changes. ServiceA and ServiceB
are located on 2 different servers on the same network.

I am struggling to find resources that cover this scenario. most articles
that discuss distributed transactions cover the scenario where 1 service
needs to update multiple data sources within a transaction.

Does anyone have any experience of handling this scenario? If so, could you
throw me a few pointers or any links you may have that can help.

Thanks
Dan
Jul 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.