public IMessageConsumer CreateQueueConsumer(string commandQueueName,
                                                    OnMessagesReceived onMessagesReceived,
                                                    string consumerId,
                                                    ConsumerConfig consumerConfig,
                                                    bool start = true)
        {
            var channel = _connection.CreateModel();

            commandQueueName = Configuration.Instance.FormatMessageQueueName(commandQueueName);

            channel.QueueDeclare(commandQueueName, true, false, false, null);
            channel.BasicQos(0, (ushort)consumerConfig.FullLoadThreshold, false);
            var consumer = new RabbitMQConsumer(channel,
                                                new [] { commandQueueName },
                                                commandQueueName,
                                                consumerId,
                                                BuildOnRabbitMQMessageReceived(onMessagesReceived),
                                                consumerConfig);

            if (start)
            {
                consumer.Start();
            }

            return(consumer);
        }
        public IMessageConsumer CreateTopicSubscription(string[] topics,
                                                        string subscriptionName,
                                                        OnMessagesReceived onMessagesReceived,
                                                        string consumerId,
                                                        ConsumerConfig consumerConfig,
                                                        bool start = true)
        {
            var channel   = _connection.CreateModel();
            var queueName = channel.QueueDeclare(subscriptionName, true, false, false, null).QueueName;

            topics.ForEach(topic =>
            {
                topic = Configuration.Instance.FormatMessageQueueName(topic);
                channel.ExchangeDeclare(topic, ExchangeType.Fanout, true, false, null);
                channel.QueueBind(queueName,
                                  topic,
                                  string.Empty);
            });

            var subscriber = new RabbitMQConsumer(channel,
                                                  topics,
                                                  queueName,
                                                  consumerId,
                                                  BuildOnRabbitMQMessageReceived(onMessagesReceived),
                                                  consumerConfig);

            if (start)
            {
                subscriber.Start();
            }

            return(subscriber);
        }