/// <summary> /// Initializes a new instance of the DispatcherManager class /// </summary> /// <param name="bindings">indicating the bindings section</param> /// <param name="observer">indicating the observer</param> /// <param name="queueFactory">indicating the queue factory</param> /// <param name="sharedData">indicating the shared data</param> /// <param name="frontendResult">indicating the frontend result</param> public DispatcherManager(BindingsSection bindings, SharedData sharedData, BrokerObserver observer, ServiceJobMonitorBase monitor, BrokerQueueFactory queueFactory, ITelepathyContext context) { this.dispatcherDic = new Dictionary <string, Dispatcher>(); this.failedDispatcherList = new List <string>(); this.blockedDispatcherDic = new Dictionary <string, DispatcherInfo>(); this.blockedDispatcherQueue = new Queue <DispatcherInfo>(); this.sharedData = sharedData; this.observer = observer; this.monitor = monitor; this.queueFactory = queueFactory; this.context = context; this.defaultCapacity = this.sharedData.ServiceConfig.MaxConcurrentCalls; this.blockTimeSpan = TimeSpan.FromMilliseconds(this.sharedData.Config.LoadBalancing.EndpointNotFoundRetryPeriod); this.unblockTimer = new Timer(new ThreadHelper <object>(new TimerCallback(this.CallbackToQueryBlockedDispatcherList)).CallbackRoot, null, -1, -1); this.defaultBinding = BindingHelper.GetBackEndBinding(bindings); this.isHttp = this.defaultBinding.CreateBindingElements().Find <HttpTransportBindingElement>() != null; // Update binding's maxMessageSize settings with global maxMessageSize if its enabled (> 0) int maxMessageSize = sharedData.ServiceConfig.MaxMessageSize; if (maxMessageSize > 0) { BindingHelper.ApplyMaxMessageSize(this.defaultBinding, maxMessageSize); } // get soa burst protocol info this.httpsBurst = sharedData.BrokerInfo.HttpsBurst; if (this.httpsBurst) { this.azureQueueManager = new AzureQueueManager(sharedData.BrokerInfo.SessionId, this.sharedData.BrokerInfo.ClusterName, this.sharedData.BrokerInfo.ClusterId); } this.supportsMessageDetails = this.defaultBinding.MessageVersion.Addressing != AddressingVersion.None || this.defaultBinding is BasicHttpBinding; BrokerTracing.TraceEvent(TraceEventType.Information, 0, "[DispatcherManager] Init backend binding: OperatiomTimeout = {0}, DefaultCapacity = {1}", this.sharedData.Config.LoadBalancing.ServiceOperationTimeout, this.defaultCapacity); BrokerTracing.EtwTrace.LogBackendBindingLoaded( sharedData.BrokerInfo.SessionId, "Backend", maxMessageSize, this.defaultBinding.ReceiveTimeout.Ticks, this.defaultBinding.SendTimeout.Ticks, this.defaultBinding.MessageVersion.ToString(), this.defaultBinding.Scheme); }
/// <summary> /// Dispose the DispatcherManager class /// </summary> /// <param name="disposing">indicating whether it is disposing</param> private void Dispose(bool disposing) { if (disposing) { this.unblockTimer.Dispose(); } if (SoaCommonConfig.WithoutSessionLayer) { this.DeleteFromHosts().GetAwaiter().GetResult(); } lock (this.lockThis) { BrokerTracing.TraceVerbose("[DispatcherManager].Dispose: Closing dispatchers..."); Dispatcher.BatchCloseDispatcher(this.dispatcherDic.Values.ToList()); BrokerTracing.TraceVerbose("[DispatcherManager].Dispose: Close all dispatchers succeeded."); } if (disposing) { if (this.azureQueueManager != null) { try { this.azureQueueManager.Close(); } catch (Exception e) { BrokerTracing.TraceError("[DispatcherManager].Dispose: Closing AzureQueueManager failed, {0}", e); } this.azureQueueManager = null; } } }