/// <summary>
        /// Receives the specified queue name.
        /// </summary>
        /// <param name="timeoutInMilliseconds">The timeout in milliseconds.</param>
        /// <param name="noOfMessagesToCache">Number of cacheable messages.</param>
        /// <returns>Message.</returns>
        public Message Receive(int timeoutInMilliseconds, int noOfMessagesToCache)
        {
            _logger.Value.DebugFormat("SqsMessageConsumer: Preparing to retrieve next message from queue {0}", _queueUrl);

            var rawSqsMessage = new SqsQueuedRetriever(_credentials).GetMessage(_queueUrl, timeoutInMilliseconds, noOfMessagesToCache).Result;

            if (rawSqsMessage == null)
            {
                return(new Message());
            }

            var sqsmessage = JsonConvert.DeserializeObject <SqsMessage>(rawSqsMessage.Body);

            var contractResolver = new MessageDefaultContractResolver();
            var settings         = new JsonSerializerSettings {
                ContractResolver = contractResolver
            };

            var message = JsonConvert.DeserializeObject <Message>(sqsmessage.Message ?? rawSqsMessage.Body, settings);

            message.Header.Bag.Add("ReceiptHandle", rawSqsMessage.ReceiptHandle);

            _logger.Value.InfoFormat("SqsMessageConsumer: Received message from queue {0}, message: {1}{2}",
                                     _queueUrl, Environment.NewLine, JsonConvert.SerializeObject(message));

            return(message);
        }
        /// <summary>
        /// Receives the specified queue name.
        /// </summary>
        /// <param name="timeoutInMilliseconds">The timeout in milliseconds.</param>
        /// <param name="noOfMessagesToCache">Number of cacheable messages.</param>
        /// <returns>Message.</returns>
        public Message Receive(int timeoutInMilliseconds, int noOfMessagesToCache)
        {
            _logger.Value.DebugFormat("SqsMessageConsumer: Preparing to retrieve next message from queue {0}", _queueUrl);

            var rawSqsMessage = new SqsQueuedRetriever(_credentials).GetMessage(_queueUrl, timeoutInMilliseconds, noOfMessagesToCache).Result;

            if(rawSqsMessage == null)
                return new Message();

            var sqsmessage = JsonConvert.DeserializeObject<SqsMessage>(rawSqsMessage.Body);

            var contractResolver = new MessageDefaultContractResolver();
            var settings = new JsonSerializerSettings { ContractResolver = contractResolver };

            var message = JsonConvert.DeserializeObject<Message>(sqsmessage.Message ?? rawSqsMessage.Body, settings);

            message.Header.Bag.Add("ReceiptHandle", rawSqsMessage.ReceiptHandle);

            _logger.Value.InfoFormat("SqsMessageConsumer: Received message from queue {0}, message: {1}{2}",
                    _queueUrl, Environment.NewLine, JsonConvert.SerializeObject(message));

            return message;
        }