コード例 #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;
                }
            }
        }
コード例 #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);
                }
            }
コード例 #3
0
ファイル: MissingPipe.cs プロジェクト: tuita520/MassTransit
        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);
            }
        }
コード例 #4
0
ファイル: MissingPipe.cs プロジェクト: tuita520/MassTransit
        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);
            }
        }
コード例 #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;
                }
            }
        }