/// <summary>
        /// Initializes a new instance of the type
        /// </summary>
        /// <param name="traceId">A unique identifier used to correlate debugging and diagnostics messages</param>
        /// <param name="componentName">The name of the component to use when writing debugging and diagnostics messages</param>
        /// <param name="serviceContext">The stateless service context that the context of the service running the listener</param>
        /// <param name="logger">A service logger used to write debugging and diagnostics messages</param>
        /// <param name="configurationProvider">The configuration provider for the gateway settings</param>
        /// <param name="unsupportedConfigurationChangeCallback">A method to call when an unsupported configuration change occurs.</param>
        public MqttCommunicationListener(Guid traceId, string componentName, StatelessServiceContext serviceContext, IServiceLogger logger, IConfigurationProvider <GatewayConfiguration> configurationProvider, UnsupportedConfigurationChange unsupportedConfigurationChangeCallback)
        {
            if (serviceContext == null)
            {
                throw new ArgumentNullException(nameof(serviceContext));
            }
            if (configurationProvider == null)
            {
                throw new ArgumentNullException(nameof(configurationProvider));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            this.logger                = logger;
            this.componentName         = componentName;
            this.serviceContext        = serviceContext;
            this.configurationProvider = configurationProvider;
            this.unsupportedConfigurationChangeCallback = unsupportedConfigurationChangeCallback;

            // optimizing IOCP performance
            int minWorkerThreads;
            int minCompletionPortThreads;

            ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);
            ThreadPool.SetMinThreads(minWorkerThreads, Math.Max(16, minCompletionPortThreads));

            this.logger.CreateCommunicationListener(traceId, this.componentName, this.GetType().FullName, this.BuildListeningAddress(this.configurationProvider.Config));
        }
        /// <summary>
        /// Initializes a new instance of the type
        /// </summary>
        /// <param name="traceId">A unique identifier used to correlate debugging and diagnostics messages</param>
        /// <param name="componentName">The name of the component to use when writing debugging and diagnostics messages</param>
        /// <param name="serviceContext">The stateless service context that the context of the service running the listener</param>
        /// <param name="logger">A service logger used to write debugging and diagnostics messages</param>
        /// <param name="configurationProvider">The configuration provider for the gateway settings</param>
        /// <param name="unsupportedConfigurationChangeCallback">A method to call when an unsupported configuration change occurs.</param>
        public MqttCommunicationListener(Guid traceId, string componentName, StatelessServiceContext serviceContext, IServiceLogger logger, IConfigurationProvider<GatewayConfiguration> configurationProvider, UnsupportedConfigurationChange unsupportedConfigurationChangeCallback)
        {
            if (serviceContext == null) throw new ArgumentNullException(nameof(serviceContext));
            if (configurationProvider == null) throw new ArgumentNullException(nameof(configurationProvider));
            if (logger == null) throw new ArgumentNullException(nameof(logger));

            this.logger = logger;
            this.componentName = componentName;
            this.serviceContext = serviceContext;
            this.configurationProvider = configurationProvider;
            this.unsupportedConfigurationChangeCallback = unsupportedConfigurationChangeCallback;

            // optimizing IOCP performance
            int minWorkerThreads;
            int minCompletionPortThreads;

            ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);
            ThreadPool.SetMinThreads(minWorkerThreads, Math.Max(16, minCompletionPortThreads));
            
            this.logger.CreateCommunicationListener(traceId, this.componentName, this.GetType().FullName, this.BuildListeningAddress(this.configurationProvider.Config));
        }