Load Ingest Data
Results 1 to 2 of 2

Thread: ADO.NET XA transactions

  1. #1
    Ignacio is offline Junior Member
    Join Date
    Nov 2006
    Posts
    18
    Rep Power
    0

    ADO.NET XA transactions

    Hi,
    Is possible include Attunity ado.net (AisConnection) into XA transactions, with adapter connect and ds connect?.
    Code i use is next:



    System.Transaction.CommittableTransaction cmtTx = new System.Transaction.CommittableTransaction();

    //Conexión a Base de Datos
    AisConnection objconection = new AisConnection();
    AisCommand cmd = new AisCommand();
    objconection.EnlistTransaction(cmtTx);

    //exec Inserts to datasource.

    //Conexión a Adapter
    AisConnection objconection2 = new AisConnection();
    AisCommand cmd = new AisCommand();
    objconection2.EnlistTransaction(cmtTx);

    //exec cics program

    .................


    cmtTx.Commit();
    or
    cmtTx.Rollback();




    Thanks.

  2. #2
    Join Date
    Sep 2006
    Posts
    233
    Rep Power
    10
    Are you following the Microsoft recommended pattern for explicit committable transaction:

    public void DoTransactionalWork()
    {
    Transaction oldAmbient = Transaction.Current;
    CommittableTransaction committableTransaction = new CommittableTransaction();
    Transaction.Current = committableTransaction;

    try
    {
    /* Perform transactional work here */
    // No errors - commit transaction asynchronously
    committableTransaction.BeginCommit(OnCommitted,nul l);
    }
    finally
    {
    //Restore the ambient transaction
    Transaction.Current = oldAmbient;
    }
    }
    void OnCommitted(IAsyncResult asyncResult)
    {
    CommittableTransaction committableTransaction;
    committableTransaction = asyncResult as CommittableTransaction;
    Debug.Assert(committableTransaction != null);
    try
    {
    using(committableTransaction)
    {
    committableTransaction.EndCommit(asyncResult);
    }
    }
    catch(TransactionException e)
    {
    //Handle the failure to commit
    }
    }

    In particular the setting of the ambient transaction with Transaction.Current
    (see Implementing an Explicit Transaction using CommittableTransaction)
    By Dror Harari

    To Find Out more About Attunity Technology:
    Attunity
    or:
    Contact Us

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •