Exemplo n.º 1
0
 internal void Begin()
 {
     try
     {
         if (_state == TransactionState.Active)
         {
             throw new InvalidOperationException("Transaction is already active");
         }
         CheckThread();
         if (_threadFlag != null)
         {
             throw new InvalidOperationException("Nested transactions are not allowed!");
         }
         _threadFlag = true;
         _startTime  = Clock.CurrentTimeMillis();
         var request = TransactionCreateCodec.EncodeRequest(_options.GetTimeoutMillis(), _options.GetDurability(),
                                                            (int)_options.GetTransactionType(), _threadId);
         var response = Invoke(request);
         _txnId = TransactionCreateCodec.DecodeResponse(response).Response;
         _state = TransactionState.Active;
     }
     catch (Exception e)
     {
         _threadFlag = null;
         throw ExceptionUtil.Rethrow(e);
     }
 }