public uint GetMessageCount <T>(PrioritySubscriptionOption <T> subscriptionOption)
        {
            uint count = 0;

            try
            {
                lock (_tunnelGate)
                {
                    for (uint level = 0; level <= subscriptionOption.MaxPriorityLevel; level++)
                    {
                        var queueName = GetPriorityQueueName <T>(subscriptionOption, level);
                        var result    = DedicatedPublishingChannel.QueueDeclarePassive(queueName);
                        if (result != null)
                        {
                            count += result.MessageCount;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _watcher.Error(ex);
            }
            return(count);
        }
        public void Publish <T>(T rabbit, uint priority, IDictionary <string, object> customHeaders)
        {
            try
            {
                //NOTE: Routing key is ignored for Headers exchange anyway
                var routingKey = _routeFinder.FindRoutingKey <T>();
                var msgBody    = _serializer.Serialize(rabbit);
                var properties = CreateBasicPropertiesForPublishing <T>();
                properties.Priority = (byte)priority;
                properties.Headers  = new Dictionary <string, object>
                {
                    { PriorityKey, priority.ToString(CultureInfo.InvariantCulture) },
                    { RoutingKey, routingKey }
                };
                if (customHeaders != null)
                {
                    foreach (var key in customHeaders.Keys)
                    {
                        if (key == null || customHeaders[key] == null)
                        {
                            continue;
                        }
                        if (PriorityKey.Equals(key, StringComparison.InvariantCultureIgnoreCase))
                        {
                            //NOTE: Do not overwrite the priority value
                            continue;
                        }

                        properties.Headers.Add(key, customHeaders[key].ToString());
                    }
                }

                var exchangeName = _routeFinder.FindExchangeName <T>();
                lock (_tunnelGate)
                {
                    DedicatedPublishingChannel.BasicPublish(exchangeName, routingKey, properties, msgBody);
                }

                if (_watcher.IsDebugEnable)
                {
                    _watcher.DebugFormat("Published to {0}, CorrelationId {1}", exchangeName, properties.CorrelationId);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Publish failed: '{0}'", ex.Message), ex);
            }
        }