Exemple #1
0
        async Task SendToInstance <T>(
            ConsumeContext <T> context, ISagaPolicy <TSaga, T> policy,
            IPipe <SagaConsumeContext <TSaga, T> > next, TSaga instance
            )
            where T : class
        {
            try
            {
                var sagaConsumeContext = new EventStoreSagaConsumeContext <TSaga, T>(_connection, context, instance);

                sagaConsumeContext.LogUsed();

                await policy.Existing(sagaConsumeContext, next).ConfigureAwait(false);

                if (!sagaConsumeContext.IsCompleted)
                {
                    await _connection.PersistSagaInstance(instance, context, _getEventMetadata);
                }
            }
            catch (SagaException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SagaException(ex.Message, typeof(TSaga), typeof(T), instance.CorrelationId, ex);
            }
        }
Exemple #2
0
            public async Task Send(SagaConsumeContext <TSaga, TMessage> context)
            {
                var instance = context.Saga;

                SagaConsumeContext <TSaga, TMessage> proxy =
                    new EventStoreSagaConsumeContext <TSaga, TMessage>(_connection, context, instance);

                proxy.LogAdded();

                await _next.Send(proxy).ConfigureAwait(false);

                if (!proxy.IsCompleted)
                {
                    await _connection.PersistSagaInstance(instance, context, _metadataFactory).ConfigureAwait(false);
                }
            }