Ejemplo n.º 1
0
        public async Task Send(SagaConsumeContext <TSaga, TMessage> context)
        {
            SagaConsumeContext <TSaga, TMessage> sagaConsumeContext = await _repositoryContext.Add(context.Saga).ConfigureAwait(false);

            sagaConsumeContext.LogAdded();

            try
            {
                await _next.Send(sagaConsumeContext).ConfigureAwait(false);
            }
            finally
            {
                switch (sagaConsumeContext)
                {
                case IAsyncDisposable asyncDisposable:
                    await asyncDisposable.DisposeAsync().ConfigureAwait(false);

                    break;

                case IDisposable disposable:
                    disposable.Dispose();
                    break;
                }
            }
        }
Ejemplo n.º 2
0
            public async Task Send(SagaConsumeContext <TSaga, TMessage> context)
            {
                context.LogAdded();

                SagaConsumeContext <TSaga, TMessage> proxy = new NHibernateSagaConsumeContext <TSaga, TMessage>(_session, context, context.Saga);

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

                if (!proxy.IsCompleted)
                {
                    await _session.SaveAsync(context.Saga).ConfigureAwait(false);
                }
            }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        public async Task Send(SagaConsumeContext <TSaga, TMessage> context)
        {
            SagaConsumeContext <TSaga, TMessage> proxy =
                _documentDbSagaConsumeContextFactory.Create(_client, _databaseName, _collectionName, context, context.Saga, false, _requestOptions);

            proxy.LogAdded();

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

            if (!proxy.IsCompleted)
            {
                await _client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(_databaseName, _collectionName), context.Saga, _requestOptions, true)
                .ConfigureAwait(false);
            }
        }
Ejemplo n.º 5
0
        public async Task Send(SagaConsumeContext <TSaga, TMessage> context)
        {
            SagaConsumeContext <TSaga, TMessage> sagaConsumeContext = await _repositoryContext.Add(context.Saga).ConfigureAwait(false);

            sagaConsumeContext.LogAdded();

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

                if (sagaConsumeContext.IsCompleted)
                {
                    await _repositoryContext.Discard(sagaConsumeContext).ConfigureAwait(false);
                }
                else
                {
                    await _repositoryContext.Save(sagaConsumeContext).ConfigureAwait(false);
                }
            }
            catch (Exception)
            {
                await _repositoryContext.Discard(sagaConsumeContext).ConfigureAwait(false);

                throw;
            }
            finally
            {
                switch (sagaConsumeContext)
                {
                case IAsyncDisposable asyncDisposable:
                    await asyncDisposable.DisposeAsync().ConfigureAwait(false);

                    break;

                case IDisposable disposable:
                    disposable.Dispose();
                    break;
                }
            }
        }