473,224 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Distributed transaction help

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
2 2767
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Morten Haugen | last post by:
Having a SQL Server 2K (SP3a) with a link to another SQL Server 2K (no service packs), distributed transactions works as expected most of the time. But occasionally the MSDTC(s) seems to fall in a...
7
by: Richard Maher | last post by:
Hi, I am seeking the help of volunteers to test some software that I've developed which facilitates distributed two-phase commit transactions, encompassing any resource manager (e.g. SQL/Server...
0
by: DotNetJunkies User | last post by:
I am writing a distributed transaction code. My current scenario include a client database(Suppose client- having 4 main database) which can be installed anywhere which would connect to a public...
1
by: Avanish Pandey | last post by:
Hello All We have 3 differen services (in 3 different server) Service A,B,C . We want to implement distributed transaction when call methods of B and C from A. Is it possible? if yes then how? ...
0
by: Raja | last post by:
I have a Linked Server i.e. my SQL Server 2000 is Linked to the Oracle Database. The Link is perfect and dont have any problems in accessing the data from SQL Server 2000. The only problem i am...
2
by: Jo Siffert | last post by:
Hi all, I would like to perform an INSERT INTO LINKEDSVR.dbo.xyz.abc SELECT ... FROM dbo.dfg where LINKEDSVR is a linked server on another machine. Both servers are running SQLServer 2000...
2
by: John Lee | last post by:
Hi, I have few questions related to .NET 2.0 TransactionScope class behavior: 1. Check Transaction.Current.TransactionInformation.DistributedIdentifier to identify if distributed transaction...
0
by: gshawn3 | last post by:
Hi, I am having a hard time creating a Trigger to update an Oracle database. I am using a SQL Server 2005 Express database on a Win XP Pro SP2 desktop, linked to an Oracle 10g database on a...
2
by: rbg | last post by:
Hi, On My local SQL server I have added a linked server to another SQL server (remoteserver) in another Windows NT Domain. When I run this code select count(*) from...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.