コード例 #1
0
        /// <summary>
        /// Handle the delivery.
        /// </summary>
        /// <param name="delivery">
        /// The delivery.
        /// </param>
        /// <returns>
        /// The message.
        /// </returns>
        /// <exception cref="Exception">
        /// </exception>
        private Message Handle(Delivery delivery)
        {
            if ((delivery == null && this.shutdown != null))
            {
                throw new Exception(string.Format("Shutdown event occurred. Cause: {0}", this.shutdown.ToString()));
            }

            if (delivery == null)
            {
                return null;
            }

            var body = delivery.Body;
            var envelope = delivery.Envelope;

            var messageProperties = RabbitUtils.CreateMessageProperties(delivery.Properties, envelope, "UTF-8");
            messageProperties.MessageCount = 0;
            var message = new Message(body, messageProperties);
            if (this.logger.IsDebugEnabled)
            {
                this.logger.Debug("Received message: " + message);
            }

            return message;
        }
コード例 #2
0
        /// <summary>Handle the delivery.</summary>
        /// <param name="delivery">The delivery.</param>
        /// <returns>The message.</returns>
        private Message Handle(Delivery delivery)
        {
            if (delivery == null && this.shutdown != null)
            {
                throw new Exception(string.Format("Shutdown event occurred. Cause: {0}", this.shutdown));
            }

            if (delivery == null)
            {
                return null;
            }

            var body = delivery.Body;
            var envelope = delivery.Envelope;

            var messageProperties = this.messagePropertiesConverter.ToMessageProperties(delivery.Properties, envelope, "UTF-8");
            messageProperties.MessageCount = 0;
            var message = new Message(body, messageProperties);
            Logger.Debug(m => m("Received message: {0}", message.ToString()));

            this.deliveryTags.AddOrUpdate(messageProperties.DeliveryTag);
            return message;
        }