PC Review


Reply
Thread Tools Rate Thread

Distributed transaction help

 
 
=?Utf-8?B?RGFuIEtlbGxleQ==?=
Guest
Posts: n/a
 
      26th Jul 2006
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
 
Reply With Quote
 
 
 
 
Hitesh Ramchandani
Guest
Posts: n/a
 
      26th Jul 2006
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" <(E-Mail Removed)> wrote in message
news:0F6E5D20-5B65-41CD-AD47-(E-Mail Removed)...
>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



 
Reply With Quote
 
Tasos Vogiatzoglou
Guest
Posts: n/a
 
      26th Jul 2006
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
transaction connection pooling and distributed transaction cristo Microsoft Dot NET 0 11th Sep 2006 02:07 PM
Detect if Distributed Transaction is used or just SQL 2005 internal transaction? John Lee Microsoft C# .NET 2 10th May 2005 04:25 AM
"Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction." Ollie Riches Microsoft C# .NET 3 11th Mar 2005 05:23 PM
"Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction." Ollie Riches Microsoft ADO .NET 3 11th Mar 2005 05:23 PM
Distributed Transaction Julián Sanz García Microsoft ADO .NET 0 22nd Sep 2004 05:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:34 AM.