コード例 #1
0
        async Task SendToInstance <T>(ConsumeContext <T> context, SqlConnection sqlConnection, ISagaPolicy <TSaga, T> policy, TSaga instance, string tableName,
                                      IPipe <SagaConsumeContext <TSaga, T> > next)
            where T : class
        {
            try
            {
                if (Log.IsDebugEnabled)
                {
                    Log.DebugFormat("SAGA:{0}:{1} Used {2}", TypeMetadataCache <TSaga> .ShortName, instance.CorrelationId, TypeMetadataCache <T> .ShortName);
                }

                var sagaConsumeContext = new DapperSagaConsumeContext <TSaga, T>(sqlConnection, context, instance, tableName);

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

                if (!sagaConsumeContext.IsCompleted)
                {
                    await UpdateSagaInstance(sqlConnection, instance).ConfigureAwait(false);
                }
            }
            catch (SagaException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SagaException(ex.Message, typeof(TSaga), typeof(T), instance.CorrelationId, ex);
            }
        }
コード例 #2
0
        async Task SendToInstance <T>(ConsumeContext <T> context, SqlConnection sqlConnection, ISagaPolicy <TSaga, T> policy, TSaga instance, string tableName,
                                      IPipe <SagaConsumeContext <TSaga, T> > next)
            where T : class
        {
            try
            {
                var sagaConsumeContext = new DapperSagaConsumeContext <TSaga, T>(sqlConnection, context, instance, tableName);

                sagaConsumeContext.LogUsed();

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

                if (!sagaConsumeContext.IsCompleted)
                {
                    await UpdateSagaInstance(sqlConnection, instance).ConfigureAwait(false);
                }
            }
            catch (SagaException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SagaException(ex.Message, typeof(TSaga), typeof(T), instance.CorrelationId, ex);
            }
        }
コード例 #3
0
            public async Task Send(SagaConsumeContext <TSaga, TMessage> context)
            {
                var sagaConsumeContext = new DapperSagaConsumeContext <TSaga, TMessage>(_sqlConnection, context, context.Saga, _tableName, false);

                sagaConsumeContext.LogAdded();

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

                if (!sagaConsumeContext.IsCompleted)
                {
                    await _insertSagaInstance(_sqlConnection, context.Saga).ConfigureAwait(false);
                }
            }
コード例 #4
0
            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 sagaConsumeContext = new DapperSagaConsumeContext <TSaga, TMessage>(_sqlConnection, context, context.Saga, _tableName, false);

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

                if (!sagaConsumeContext.IsCompleted)
                {
                    await _insertSagaInstance(_sqlConnection, context.Saga).ConfigureAwait(false);
                }
            }