Apache.NMS.ActiveMQ.TransactionContext.SinglePhaseCommit C# (CSharp) Method

SinglePhaseCommit() public method

public SinglePhaseCommit ( SinglePhaseEnlistment enlistment ) : void
enlistment SinglePhaseEnlistment
return void
        public void SinglePhaseCommit(SinglePhaseEnlistment enlistment)
        {
            try
            {
                dtcControlEvent.Reset();

                Tracer.Debug("Single Phase Commit notification received for TX id: " + this.transactionId);

                if (this.transactionId != null)
                {
                    BeforeEnd();

                    // Now notify the broker that a new XA'ish transaction has completed.
                    TransactionInfo info = new TransactionInfo();
                    info.ConnectionId = this.connection.ConnectionId;
                    info.TransactionId = this.transactionId;
                    info.Type = (int) TransactionType.CommitOnePhase;

                    this.connection.CheckConnected();
                    this.connection.SyncRequest(info);

                    Tracer.Debug("Transaction Single Phase Commit Done TX id: " + this.transactionId);

                    // if server responds that nothing needs to be done, then reply done.
                    enlistment.Done();

                    AfterCommit();
                }
            }
            catch(Exception ex)
            {
                Tracer.DebugFormat("Transaction[{0}] Single Phase Commit failed with error: {1}",
                                   this.transactionId, ex.Message);
                AfterRollback();
                enlistment.Done();
                try
                {
                    this.connection.OnException(ex);
                }
                catch (Exception error)
                {
                    Tracer.Error(error.ToString());
                }
            }
            finally
            {
                this.currentEnlistment = null;
                this.transactionId = null;

                this.dtcControlEvent.Set();
            }
        }