コード例 #1
0
        private List <ITransactionSynchronization> DoSuspendSynchronization()
        {
            var suspendedSynchronizations = TransactionSynchronizationManager.GetSynchronizations();

            foreach (var synchronization in suspendedSynchronizations)
            {
                synchronization.Suspend();
            }

            TransactionSynchronizationManager.ClearSynchronization();
            return(suspendedSynchronizations);
        }
コード例 #2
0
        private void TriggerAfterCompletion(DefaultTransactionStatus status, int completionStatus)
        {
            if (status.IsNewSynchronization)
            {
                var synchronizations = TransactionSynchronizationManager.GetSynchronizations();
                TransactionSynchronizationManager.ClearSynchronization();
                if (!status.HasTransaction || status.IsNewTransaction)
                {
                    _logger?.LogTrace("Triggering afterCompletion synchronization");

                    // No transaction or new transaction for the current scope ->
                    // invoke the afterCompletion callbacks immediately
                    InvokeAfterCompletion(synchronizations, completionStatus);
                }
                else if (synchronizations.Count > 0)
                {
                    // Existing transaction that we participate in, controlled outside
                    // of the scope of this Spring transaction manager -> try to register
                    // an afterCompletion callback with the existing (JTA) transaction.
                    RegisterAfterCompletionWithExistingTransaction(status.Transaction, synchronizations);
                }
            }
        }