private void ReceiveFromQueue(MessageEx message, Action<MessageEx> processMessageAction)
		{
			var m = message.Message;
			if (m == null)
			{
				Logger.Info(LoggerContext.New(message.MessageOrigin.Name), string.Format("Peek returned null message."));
				return;
			}

			message.DoReceive();
			processMessageAction(message);
		}
        private void ReceiveFromQueue(MessageEx message)
        {
            var m = message.Message;
            if (m == null)
            {
                return;
            }

            message.DoReceive();

            _messageId = m.Id;
            if (IsTransactional)
            {
                if (HandledMaxRetries(m.Id))
                {
                    Logger.Error(LoggerContext.New(message.MessageOrigin.Name), string.Format("Message has failed the maximum number of times allowed, ID={0}.", m.Id));
                    MoveToErrorQueue(message);
                    return;
                }
            }
            //exceptions here will cause a rollback - which is what we want.
            if (StartedMessageProcessing != null)
            {
                StartedMessageProcessing(this, null);
            }
            TransportMessage result = Convert(m);
            if (SkipDeserialization)
            {
                result.BodyStream = m.BodyStream;
            }
            else
            {
                try
                {
                    result.Body = Extract(m);
                }
                catch (Exception e)
                {
                    Logger.Error(LoggerContext.New(message.MessageOrigin.Name, result), "Could not extract message data.", e);
                    MoveToErrorQueue(message);
                    OnFinishedMessageProcessing(message); // don't care about failures here
                    return; // deserialization failed - no reason to try again, so don't throw
                }
            }
            //care about failures here
            var exceptionNotThrown = OnTransportMessageReceived(result, message);
            //and here
            var otherExNotThrown = OnFinishedMessageProcessing(message);
            //but need to abort takes precedence - failures aren't counted here,
            //so messages aren't moved to the error queue.
            if (_needToAbort)
            {
                throw new AbortHandlingCurrentMessageException();
            }
            if (!(exceptionNotThrown && otherExNotThrown)) //cause rollback
            {
                throw new ApplicationException("Exception occured while processing message.");
            }
        }