Beispiel #1
0
 public void CloseOnTimeout()
 {
     // TODO: CTX返回TransactionTimeout异常
     if (_txCtx == null)
     {
         throw new Exception("TccTransactionContext is  Null");
     }
     _txCtx.ThrowException("Transaction TimeOut Error", null);
 }
Beispiel #2
0
        public void BeginExecute(Action <TccTransactionContext <TContext> > callback)
        {
            lock (_syncRoot) {
                if (_txCtx != null)
                {
                    throw new NotSupportedException("[BUG] BeginInvoke for every TccTransaction can only run once");
                }

                _txCtx     = new TccTransactionContext <TContext>(this, callback);
                _txState   = _lock != null ? TccTransactionState.LockTrying : TccTransactionState.Trying;
                _beginTime = DateTime.Now;
            }

            try {
                CheckAndRunNext(null);
            } catch (Exception ex) {
                _txCtx.ThrowException("[BUG] BeginExecute CheckAndRunNext Failed", ex);
            }
        }
Beispiel #3
0
        public void BeginReclose(Action <TccTransactionContext <TContext> > callback)
        {
            //
            // TODO:尝试重新关闭Transaction,当Confirm或者Cancel Failed
            //
            // ?: 当从Persister当中序列化出来的时候,应当怎样去操作
            //
            // Confirming & ConfirmFailed   :  继续confirm
            // Cancelling & cancelFailed    :  继续cancel
            // Trying                       :  cancel
            //
            if (_txCtx != null)
            {
                throw new NotSupportedException("TccTransactionContext is not Null");
            }
            _txCtx = new TccTransactionContext <TContext>(this, callback);
            lock (_syncRoot)
            {
                if (_txState == TccTransactionState.CancelFailed || _txState == TccTransactionState.Cancelling || _txState == TccTransactionState.Trying)
                {
                    _txState = TccTransactionState.Cancelling;
                }
                else if (_txState == TccTransactionState.ConfirmFailed || _txState == TccTransactionState.Confirming)
                {
                    _txState = TccTransactionState.Confirming;
                }
                else
                {
                    throw new NotSupportedException("TccTransactionState can not Reclose:" + _txState.ToString());
                }
            }

            try
            {
                CheckAndRunNext(null);
            }
            catch (Exception ex)
            {
                _txCtx.ThrowException("[BUG] BeginClose CheckAndRunNext Failed", ex);
            }
        }