Exemplo n.º 1
0
 async Task RemoveNewSaga(SagaInstance <TSaga> instance, CancellationToken cancellationToken)
 {
     if (_withinLock)
     {
         _repository.RemoveWithinLock(instance);
     }
     else
     {
         await _repository.Remove(instance, cancellationToken).ConfigureAwait(false);
     }
 }
 async Task RemoveNewSaga(TSaga saga, CancellationToken cancellationToken)
 {
     if (_withinLock)
     {
         _repository.RemoveWithinLock(saga);
     }
     else
     {
         await _repository.Remove(saga, cancellationToken).ConfigureAwait(false);
     }
 }
Exemplo n.º 3
0
        public async Task SetCompleted()
        {
            await _repository.Remove(Saga, CancellationToken);

            IsCompleted = true;
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("SAGA:{0}:{1} Removed {2}", TypeMetadataCache <TSaga> .ShortName, Saga.CorrelationId,
                                 TypeMetadataCache <TMessage> .ShortName);
            }
        }
            public async Task Send(SagaConsumeContext <TSaga, TMessage> context)
            {
                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("SAGA:{0}:{1} Added {2}", TypeMetadataCache <TSaga> .ShortName, context.Saga.CorrelationId,
                                     TypeMetadataCache <TMessage> .ShortName);
                }

                var proxy = new InMemorySagaConsumeContext <TSaga, TMessage>(_repository, context, context.Saga);

                await _repository.Add(context.Saga, context.CancellationToken);

                await _next.Send(proxy);

                if (proxy.IsCompleted)
                {
                    await _repository.Remove(proxy.Saga, context.CancellationToken);
                }
            }