async Task SendToInstance <T>(ConsumeContext <T> context, ISagaPolicy <TSaga, T> policy, IPipe <SagaConsumeContext <TSaga, T> > next, TSaga instance) where T : class { try { SagaConsumeContext <TSaga, T> sagaConsumeContext = _mongoDbSagaConsumeContextFactory.Create(_collection, context, instance); sagaConsumeContext.LogUsed(); await policy.Existing(sagaConsumeContext, next).ConfigureAwait(false); if (!sagaConsumeContext.IsCompleted) { await UpdateMongoDbSaga(context, instance).ConfigureAwait(false); } } catch (SagaException sex) { context.LogFault(this, sex, instance?.CorrelationId); throw; } catch (Exception ex) { throw new SagaException(ex.Message, typeof(TSaga), typeof(T), instance.CorrelationId, ex); } }
async Task SendToInstance <T>(ConsumeContext <T> context, ISagaPolicy <TSaga, T> policy, IPipe <SagaConsumeContext <TSaga, T> > next, TSaga instance) where T : class { try { if (_log.IsDebugEnabled) { _log.DebugFormat("SAGA:{0}:{1} Used {2}", TypeMetadataCache <TSaga> .ShortName, instance.CorrelationId, TypeMetadataCache <T> .ShortName); } SagaConsumeContext <TSaga, T> sagaConsumeContext = _mongoDbSagaConsumeContextFactory.Create(_collection, context, instance); await policy.Existing(sagaConsumeContext, next).ConfigureAwait(false); await UpdateMongoDbSaga(context, instance).ConfigureAwait(false); } catch (SagaException) { throw; } catch (Exception ex) { throw new SagaException(ex.Message, typeof(TSaga), typeof(T), instance.CorrelationId, ex); } }
public async Task Send(SagaConsumeContext <TSaga, TMessage> context) { SagaConsumeContext <TSaga, TMessage> proxy = _mongoDbSagaConsumeContextFactory.Create(_collection, context, context.Saga, false); proxy.LogAdded(); await _next.Send(proxy).ConfigureAwait(false); if (!proxy.IsCompleted) { await _collection.InsertOneAsync(context.Saga).ConfigureAwait(false); } }
public async Task Send(SagaConsumeContext <TSaga, TMessage> context) { if (_log.IsDebugEnabled) { _log.DebugFormat("SAGA:{0}:{1} Added {2}", TypeMetadataCache <TSaga> .ShortName, TypeMetadataCache <TMessage> .ShortName); } var proxy = _mongoDbSagaConsumeContextFactory.Create(_collection, context, context.Saga, false); await _next.Send(proxy).ConfigureAwait(false); if (!proxy.IsCompleted) { await _collection.InsertOneAsync(context.Saga).ConfigureAwait(false); } }