[Mono-list] Web Services asynchronously

Michał Ziemski rook at roo.k.pl
Wed Jun 11 11:24:46 EDT 2008


Hi!

Most probably the transaction will be rolled back when myTran will be 
finalized.
You should wrap myTrans, cmd, cmd2, etc with "using" so as not to be 
dependent on the finalizer.

Cheers!
Michał Ziemski

Luciano _ pisze:
> Hi:
>      I have a question about the Web Services, and how it works on mono.
>  
> I have a WebServices (running in apache with mod_mono) that use 
> MySqlConnector to connect mysql server on the same machine. Within 
> this WS i make some operations (Insert's and update's) in a 
> transaction operation.
>
> I'm consuming this WS with a GtkSharp app, this app calls the WS 
> asynchronously, with CallBack.
> My Question is, if the services is aborted in the middle of the 
> transaction, the transaction will be rolled back? Or not? I test it, 
> and i think yes, but i need to know if always be rolled back, or maybe 
> sometimes no. My doubt is that maybe if the operation has terminated 
> the transaction but the services is not finished and services is 
> aborted, the services will be aborted but the transaction will be 
> commited. Is the connection (i use a Using statement) correctly disposed?
>  
> The WS method (pseudo-code) will be like this:
>
> [WebMethod()]
> public void TestAsync()
> {
>     using(MySqlConnection conn = new 
> MySqlConnection("....ConnectionString..."))
>     {
>              conn.Open();
>              MySqlTransaction myTran = conn.BeginTransaction();
>  
>              MySqlCommand cmd = new mySqlCommand();
>              cmd.Transaction = myTran;
>              cmd.CommandText = "INSERT INTO SOME TABLE;"
>              cmd.ExecuteNonQuery();
>  
>              // If the abort call is in this moment, the transaction 
> is rolled back? The connection is correctly disposed and closed?
>  
>              MySqlCommand cmd2 = new mySqlCommand();
>              cmd2.Transaction = myTran;
>              cmd2.CommandText = "UPDATE SOME TABLE;"
>              cmd2.ExecuteNonQuery();
>  
>              // If the abort call is at this moment the transaction is 
> rolled back?
>              myTran.Commit();
>          
>              // If the abort call is at this moment the transaction is 
> NOT rolled back?
>              conn.Close();
>     }
>    // The Using Statement is executing the Dispose method if i call 
> Abort() ?
>  
> }
>  
>  
> Thanks a lot in advanced, i will really appreciate help.
>
> Luciano
>
> ------------------------------------------------------------------------
> Stop squinting -- view your photos on your TV. Learn more 
> <http://www.microsoft.com/windows/digitallife/default.mspx?deepLink=photos> 
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>   



More information about the Mono-list mailing list