Esempio n. 1
0
        /// <inheritdoc />
        public async Task <IReceivedMessageInternal> ReceiveMessageAsync(IMessageContext context)
        {
            //we can't attach the span since we don't have the parent until after we get a message
            //so save off the start and end times, and replace those in the child span below
            var start   = DateTime.UtcNow;
            var message = await _handler.ReceiveMessageAsync(context);

            var end = DateTime.UtcNow;

            if (message == null)
            {
                return(null);
            }
            var spanContext = message.Extract(_tracer, _headers.StandardHeaders);

            if (spanContext != null)
            {
                using (IScope scope = _tracer.BuildSpan("ReceiveMessage").AddReference(References.FollowsFrom, spanContext).WithStartTimestamp(start)
                                      .StartActive(finishSpanOnDispose: true))
                {
                    scope.Span.AddMessageIdTag(message);
                    scope.Span.Finish(end);
                    return(message);
                }
            }
            using (IScope scope = _tracer.BuildSpan("ReceiveMessage").WithStartTimestamp(start).StartActive(finishSpanOnDispose: true))
            {
                scope.Span.AddMessageIdTag(message);
                scope.Span.Finish(end);
                return(message);
            }
        }
Esempio n. 2
0
        /// <inheritdoc />
        public async Task <IReceivedMessageInternal> ReceiveMessageAsync(IMessageContext context)
        {
            IReceivedMessageInternal result = null;

            if (_policyAsync == null)
            {
                _policies.Registry.TryGet(_policies.Definition.ReceiveMessageFromTransportAsync, out _policyAsync);
            }

            if (_policyAsync != null)
            {
                await _policyAsync.ExecuteAsync(async() => result = await _handler.ReceiveMessageAsync(context).ConfigureAwait(false)).ConfigureAwait(false);
            }
            else //no policy found
            {
                result = await _handler.ReceiveMessageAsync(context).ConfigureAwait(false);
            }
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns a message to process.
        /// </summary>
        /// <param name="context">The message context.</param>
        /// <returns>
        /// A message to process or null if there are no messages to process
        /// </returns>
        public async Task <IReceivedMessageInternal> ReceiveMessageAsync(IMessageContext context)
        {
            var result = await _handler.ReceiveMessageAsync(context).ConfigureAwait(false);

            if (result != null)
            {
                ProcessResult(result);
            }
            return(result);
        }