public void MoveToSubQueue(Type messageType, Message message)
        {
            var helper = new PendingQueueHelper(bus);

            using (var queue = helper.GetQueue(messageType))
            {
                queue.MoveToSubQueue(SubQueueName, message);
            }
        }
        public void ProcessMessage(Type messageType, Task<Message> task)
        {
            if (task.Result == null || String.IsNullOrWhiteSpace(task.Result.Id))
            {
                return;
            }

            var helper = new PendingQueueHelper(bus);
            helper.MoveToSubQueue(messageType, task.Result);

            IMessageHandler handler = BusConfiguration.Configure.GetHandler(messageType);
            bool handled = false;

            if (handler != null)
            {
                var message = task.Result.Body as IMessage;

                if (message != null)
                {
                    handled = HandleMessage(task, handler, message);
                }
                else
                {
                    var messages = task.Result.Body as IMessage[];

                    if (messages != null)
                    {
                        handled = HandleMessages(task, handler, messages);
                    }
                }
            }

            if (handled)
            {
                bus.Advanced.Remove(messageType, task.Result.Id);
            }
            else
            {
                Thread.Sleep(bus.Settings.MinRetryTimeout);
                helper.MoveFromSubQueue(messageType, task.Result);
            }
        }