BizTalk Server Orchestration - COM ServicedComponent Rollback fails

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > May 2006 > COM ServicedComponent Rollback fails





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author COM ServicedComponent Rollback fails
ee@ee.demon.co.uk

2006-05-08, 7:14 pm

Hi All,

I am wondering if anyone can point me in the right direction.

I have attached a word document containing screenshots of the problem. I am
should the solution is quite simple.



I have a simple scenario where I call a .Net function, which updates a row
in a DB table. The function uses COM+ transactions when it does the update:

[assembly: ApplicationAccessControl(true)]
namespace MyNamespace
{
[ClassInterface(ClassInterfaceType.AutoDual)]
[Transaction(TransactionOption.Required)]
[ComVisible(true)]
[CLSCompliant(false)]
public class MyComsPlusClass : ServicedComponent
{
[AutoComplete]
public static void UpdateRow()
{
using (SqlConnection sqlConn = new SqlConnection())
{
sqlConn.ConnectionString = GetConnString();

SqlCommand sqlCmd = new SqlCommand("sp _UpdateRow",
sqlConn);
sqlCmd.CommandType = CommandType.StoredProcedure;

if (sqlConn.State != System.Data.ConnectionState.Open)
sqlConn.Open();

sqlCmd.ExecuteNonQuery();

sqlConn.Close();
}
}


I call it from an ACID scope within a Long Running scope. The transaction
type, Serializable, is the same for both the ACID scope and the .Net COM+
class.

I have a compensation block in the orchestration, which I can see fires in
the debugger but does not rollback the DB update.

It is not a problem with the .Net ServicedComponent. I know this because if
I call the UpdateRow() from another ServicedComponent derived component I
wrote everything woks perfectly!

It only doesn't work when I call the same ServicedComponent from an
orchestration?

Maybe it is became I need to call the .Net ServicedComponent and set the
transaction context or something?

See screenshot for details of orchestration.

There seems to be NOT example. I am amazed that no one has use transactions
from within an orchestration.

Thanks in advance,
Jim
Tomas Restrepo \(MVP\)

2006-05-08, 7:14 pm

>
> I am wondering if anyone can point me in the right direction.
>
> I have attached a word document containing screenshots of the problem. I
> am
> should the solution is quite simple.
>
>
>
> I have a simple scenario where I call a .Net function, which updates a row
> in a DB table. The function uses COM+ transactions when it does the
> update:
>
> [assembly: ApplicationAccessControl(true)]
> namespace MyNamespace
> {
> [ClassInterface(ClassInterfaceType.AutoDual)]
> [Transaction(TransactionOption.Required)]
> [ComVisible(true)]
> [CLSCompliant(false)]
> public class MyComsPlusClass : ServicedComponent
> {
> [AutoComplete]
> public static void UpdateRow()
> {
> using (SqlConnection sqlConn = new SqlConnection())
> {
> sqlConn.ConnectionString = GetConnString();
>
> SqlCommand sqlCmd = new SqlCommand("sp _UpdateRow",
> sqlConn);
> sqlCmd.CommandType = CommandType.StoredProcedure;
>
> if (sqlConn.State != System.Data.ConnectionState.Open)
> sqlConn.Open();
>
> sqlCmd.ExecuteNonQuery();
>
> sqlConn.Close();
> }
> }
> .
>
> I call it from an ACID scope within a Long Running scope. The transaction
> type, Serializable, is the same for both the ACID scope and the .Net COM+
> class.
>
> I have a compensation block in the orchestration, which I can see fires in
> the debugger but does not rollback the DB update.


Why would the transaction be rollback on the compensation ? The compensation
should only fire because something causes the external long running
transaction to fail, which triggers the compensation actions. The atomic
transaction has already completed and committed at that point.

IOW, the atomic transaction will only roll back if an error ocurrs within
the execution of the atomic scope itself!

In your scenario, the compensation should try to manually undo the effects
of the atomic transaction to manually "rollback" the long running
transaction. A completely different thing.


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


ee@ee.demon.co.uk

2006-05-09, 7:15 am


Thanks for your response.

If I call the .Net COM+ method from within an ATOMIC scope, and in that
method it updates a DB row and then throw an exception. The Biztalk
orchestration does not automatically rollback.

If I call exactly the same component from another .Net COM+ method in
another .Net application everything works fine!

Form some reason the orchestration ATOMIC scope is not wrapping the .Net
COM+ component in a transaction COM+.

The have the same isolation level...

Do I need to link the .Net COM+ class to the actual “Transaction Identifier”
(where you can specify a name for the transaction, e.g. UpdateTrans).

Is there an example I can download?
Anything else I can try?
Anyone else had this problem?

Thank in advance

Jim
Tomas Restrepo \(MVP\)

2006-05-09, 7:15 am

> Thanks for your response.
>
> If I call the .Net COM+ method from within an ATOMIC scope, and in that
> method it updates a DB row and then throw an exception. The Biztalk
> orchestration does not automatically rollback.


What's your method like, then?


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


ee@ee.demon.co.uk

2006-05-09, 7:14 pm

Hi,
I will respond tomorrow.

I will do a few tests.

Are there any example with BizTake?
thanks mate.


Regards,

Jim
ee@ee.demon.co.uk

2006-05-10, 7:17 am


COM+ transaction method
[AutoComplete]
public static void UpdateRow1()
{
using (SqlConnection sqlConn = new SqlConnection())
{
sqlConn.ConnectionString = GetConnString();

SqlCommand sqlCmd = new SqlCommand("sp__UpdateRow",
sqlConn);
sqlCmd.CommandType = CommandType.StoredProcedure;

if (sqlConn.State != System.Data.ConnectionState.Open)
sqlConn.Open();

sqlCmd.ExecuteNonQuery();

sqlConn.Close();
}
}



private void TesterApp()
{
using (DAL.ComTest comTest = new DAL.ComTest())
{
comTest.UpdateRow1();

comTest.UpdateRow2();

comTest.UpdateRow3(); // Rasies an exception
}
}
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com