示例#1
0
        protected override bool Receive(object message)
        {
            var terminated = message as Terminated;

            if (terminated != null)
            {
                if (_currentTransactionId == Guid.Empty)
                {
                    var rollback = new Rollback(_currentTransactionId, new ActorTerminatedException(terminated.ActorRef));
                    _participants.ExceptWith(new[] { terminated.ActorRef });

                    foreach (var participant in _participants)
                    {
                        participant.Tell(rollback);
                    }

                    Become(PhaseTwo);

                    return(true);
                }
            }
            else if (message is ReceiveTimeout)
            {
                foreach (var participant in _participants)
                {
                    participant.Tell(new Rollback(_currentTransactionId, new Exception(string.Format("Transaction {0} has reached it's ACK timeout", _currentTransactionId))));
                }

                Context.Stop(Self);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Raises the <see cref="Rollback"/> event.
        /// </summary>
        /// <returns><c>true</c> if handler does not set the <see cref="WizardPageConfirmEventArgs.Cancel"/> to <c>true</c>; otherwise, <c>false</c>.</returns>
        protected virtual bool OnRollback()
        {
            var e = new WizardPageConfirmEventArgs(this);

            Rollback?.Invoke(this, e);
            return(!e.Cancel);
        }
示例#3
0
        public static MigratorOptions CreateRollbackBy(Rollback cmd, int?steps)
        {
            var result = new MigratorOptions("rollback")
                         .Init(cmd);

            result.Steps           = steps;
            result.TransactionMode = cmd.TransactionMode;
            return(result);
        }
示例#4
0
        private void OnRollback(Rollback _)
        {
            if (lastEvent is TransferStarted)
            {
                // compensating action - we ordered withdraw already, now order a deposit back withdrawn amount
                replyTo.Tell(new Deposit(PersistenceId, amount));
            }
            if (lastEvent is Withdrawn)
            {
                // compensating action - we ordered withdraw and deposit already,
                // now we need to rollback both of these operations
                accountShardRegion.Tell(new ShardEnvelope <Withdraw>(toAccount, new Withdraw(PersistenceId, amount)));
                replyTo.Tell(new Deposit(PersistenceId, amount));
            }

            replyTo.Tell(new TransferFailed(PersistenceId, new Exception("Couldn't finish transfer transaction, rollback has been called")));
            Context.Stop(Self);
        }
        protected bool PhaseOne(object message)
        {
            var wasHandled = Receive(message);

            if (!wasHandled)
            {
                var transaction = message as ITransactionMessage;
                if (transaction != null && transaction.TransactionId == _currentTransactionId)
                {
                    return(transaction.Match()
                           .With <Continue>(cont =>
                    {
                        // wait for all participants to confirm
                        _phaseTwoPending.Add(Sender);
                        _phaseOnePending.Remove(Sender);

                        // when all participants confirmed, send Commit and go to phase two
                        if (_phaseOnePending.Count == 0)
                        {
                            var commit = new Commit(_currentTransactionId);
                            foreach (var participant in _phaseTwoPending)
                            {
                                participant.Tell(commit);
                            }

                            Become(PhaseTwo);
                        }
                    })
                           .With <Abort>(_ =>
                    {
                        var rollback = new Rollback(_currentTransactionId, new TransactionAbortedException());
                        foreach (var participant in _participants)
                        {
                            participant.Tell(rollback);
                        }

                        Become(PhaseTwo);
                    })
                           .WasHandled);
                }
            }

            return(wasHandled);
        }
        protected override bool Receive(object message)
        {
            var terminated = message as Terminated;

            if (terminated != null)
            {
                if (_currentTransactionId == Guid.Empty)
                {
                    var rollback = new Rollback(_currentTransactionId, new ActorTerminatedException(terminated.ActorRef));
                    _participants.ExceptWith(new[] { terminated.ActorRef });

                    foreach (var participant in _participants)
                    {
                        participant.Tell(rollback);
                    }

                    Become(PhaseTwo);

                    return(true);
                }
            }

            return(false);
        }
 public NHibernateContextAttribute(Rollback rollback)
 {
     _rollback = rollback;
 }
示例#8
0
    // Start is called before the first frame update
    void Start()
    {
        positions = new List <Vector2>();

        rollback = GetComponent <Rollback>();
    }
        protected override bool Receive(object message)
        {
            var terminated = message as Terminated;
            if (terminated != null)
            {
                if (_currentTransactionId == Guid.Empty)
                {
                    var rollback = new Rollback(_currentTransactionId, new ActorTerminatedException(terminated.ActorRef));
                    _participants.ExceptWith(new[] { terminated.ActorRef });

                    foreach (var participant in _participants)
                    {
                        participant.Tell(rollback);
                    }

                    Become(PhaseTwo);

                    return true;
                }
            }
            else if (message is ReceiveTimeout)
            {
                foreach (var participant in _participants)
                {
                    participant.Tell(new Rollback(_currentTransactionId, new Exception(string.Format("Transaction {0} has reached it's ACK timeout", _currentTransactionId))));
                }
                
                Context.Stop(Self);
            }

            return false;
        }
        protected bool PhaseOne(object message)
        {
            var wasHandled = Receive(message);
            if (!wasHandled)
            {
                var transaction = message as ITransactionMessage;
                if (transaction != null && transaction.TransactionId == _currentTransactionId)
                {
                    return transaction.Match()
                        .With<Continue>(cont =>
                        {
                            // wait for all participants to confirm
                            _phaseTwoPending.Add(Sender);
                            _phaseOnePending.Remove(Sender);

                            // when all participants confirmed, send Commit and go to phase two
                            if (_phaseOnePending.Count == 0)
                            {
                                var commit = new Commit(_currentTransactionId);
                                foreach (var participant in _phaseTwoPending)
                                {
                                    participant.Tell(commit);
                                }

                                Become(PhaseTwo);
                            }
                        })
                        .With<Abort>(_ =>
                        {
                            var rollback = new Rollback(_currentTransactionId, new TransactionAbortedException());
                            foreach (var participant in _participants)
                            {
                                participant.Tell(rollback);
                            }

                            Become(PhaseTwo);
                        })
                        .WasHandled;
                }
            }

            return wasHandled;
        }
 public bool IsValid() => Upgrade.AreValid() &&
 Rollback.AreValid() &&
 Downgrade.AreValid();