using nested transactions

Posts   
 
    
jon
User
Posts: 2
Joined: 27-Jul-2005
# Posted on: 27-Jul-2005 17:37:13   

Hi,

I have got the following scenario...

We follow Service Oriented architecture. There are 2 webmethods say Webmethod1 and Webmethod2 where I call the stored procedures. I used transactions in each of the webmethods. Webmethod2 should be executed only after Webmethod1.

In the front end, I call Webmethod1 and if it succeeds, I will call Webmethod2.

The business rule is - if either of the webmethods fail, both the stored procedures should rollback. ie. if webmethod2 rollsback, then webmethod1 should "also rollback".

eg. bool chk = false; chk = webmethod1(); //commits stored procedure1 if succeeds if (chk) { chk = webmethod2(); //commits stored procedure2 if succeeds if (!chk) //if error { //Stored procedure executed in webmethod1 should be rollback //which becomes a problem } }

This becomes the problem. As I commit the stored procedure in Webmethod1, there is no way to rollback if there is an error in Webmethod2. I cannot combine these 2 stored procedures into one webmethod because "not always webmethod2 is called after webmethod1". So, the solution I could think of is to use nested transactions.

Please advice me on how to use the nested transactions. I have got 4-5 webmethods which have to be called in sequence (not combinable into 1 method) and if anything fails, all the webmethods have to be rolledback.

Thanks, Jon

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 27-Jul-2005 19:06:31   

A 2-phase commit action on webservices I think, but still not very solid. Is it ok if I move this thread to Architecture?

Frans Bouma | Lead developer LLBLGen Pro
jon
User
Posts: 2
Joined: 27-Jul-2005
# Posted on: 27-Jul-2005 20:17:16   

Otis wrote:

A 2-phase commit action on webservices I think, but still not very solid. Is it ok if I move this thread to Architecture?

2-phase commit would be the best way I guess. But I am not sure how to use it through llblgen. It would be great if you can give me a link or an example...

Infact, I started this thread in the architecture but again somehow felt that this involves the generated code and put in this one. You can move this to Architecture.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 28-Jul-2005 11:17:58   

jon wrote:

Otis wrote:

A 2-phase commit action on webservices I think, but still not very solid. Is it ok if I move this thread to Architecture?

2-phase commit would be the best way I guess. But I am not sure how to use it through llblgen. It would be great if you can give me a link or an example...

from our own forum: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=3418

Infact, I started this thread in the architecture but again somehow felt that this involves the generated code and put in this one. You can move this to Architecture.

Moved simple_smile

Frans Bouma | Lead developer LLBLGen Pro