public async Task Send(SendContext <T> context)
        {
            context.SourceAddress = _sourceAddress;

            if (_consumeContext != null)
            {
                context.TransferConsumeContextHeaders(_consumeContext);
            }

            var publishContext = context.GetPayload <PublishContext <T> >();

            var firstTime = Interlocked.CompareExchange(ref _context, publishContext, null) == null;

            await _publishPipe.Send(publishContext).ConfigureAwait(false);

            if (_pipe.IsNotEmpty())
            {
                await _pipe.Send(publishContext).ConfigureAwait(false);
            }

            if (firstTime)
            {
                await _observer.PrePublish(publishContext).ConfigureAwait(false);
            }
        }
Пример #2
0
        public async Task Send(SendContext <T> context)
        {
            if (_consumeContext != null)
            {
                context.TransferConsumeContextHeaders(_consumeContext);
            }

            if (_pipe.IsNotEmpty())
            {
                await _pipe.Send(context).ConfigureAwait(false);
            }
        }
        public async Task Send(SendContext <T> context)
        {
            if (_consumeContext != null)
            {
                context.TransferConsumeContextHeaders(_consumeContext);
            }

            context.SourceAddress = _sourceAddress;

            var publishContext = new PublishContextProxy <T>(context, context.Message);
            var firstTime      = Interlocked.CompareExchange(ref _context, publishContext, null) == null;

            await _publishPipe.Send(publishContext).ConfigureAwait(false);

            await _pipe.Send(publishContext).ConfigureAwait(false);

            if (firstTime)
            {
                await _observer.PrePublish(publishContext).ConfigureAwait(false);
            }
        }