Example #1
0
        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 && _observer.Count > 0)
            {
                await _observer.PrePublish(publishContext).ConfigureAwait(false);
            }
        }
Example #2
0
 public Task PrePublish(PublishContext <TMessage> context)
 {
     return(_observer.PrePublish(context));
 }