public MessageDispatcher(StatefulServiceContext context)
            : base(context)
        {
            this.components = new ComponentManager(nameof(MessageDispatcher), "RootContainer");

            var partitionSetting            = DispatcherPartitionSetting.Create();
            var resultReporter              = ResultReporter.Create();
            var inputMessageFilteringEngine = InputMessageFilteringEngine.Create(partitionSetting.InstantQueueSetting, resultReporter);

            // Delayed Queue
            IReliableLog <OutputMessage> nextOutputReliableLog = null;

            for (var i = partitionSetting.DelayedQueueSettings.Count - 1; i >= 0; i--)
            {
                var setting = partitionSetting.DelayedQueueSettings[i];
                var outputMessageFilteringEngine = OutputMessageFilteringEngine.Create(setting, inputMessageFilteringEngine, resultReporter);
                var outputReliableLog            = ReliableLog <OutputMessage> .Create(setting, this.StateManager);

                outputReliableLog = new DelayedReliableLog(outputReliableLog);
                var outputMessageProcessor = MessageProcessor <OutputMessage> .Create(
                    setting,
                    outputReliableLog,
                    nextOutputReliableLog ?? outputReliableLog,
                    outputMessageFilteringEngine,
                    resultReporter);

                this.components.Add(outputMessageFilteringEngine);
                this.components.Add(outputReliableLog);
                this.components.Add(outputMessageProcessor);

                nextOutputReliableLog = outputReliableLog;
            }

            // Instant Queue
            var inputReliableLog = ReliableLog <InputMessage> .Create(partitionSetting.InstantQueueSetting, this.StateManager);

            var inputMessageProcessor = MessageProcessor <InputMessage> .Create(
                partitionSetting.InstantQueueSetting,
                inputReliableLog,
                nextOutputReliableLog,
                inputMessageFilteringEngine,
                resultReporter);

            this.components.Add(inputMessageFilteringEngine);
            this.components.Add(inputReliableLog);
            this.components.Add(inputMessageProcessor);
            this.components.Add(resultReporter);

            this.inputReliableLog = inputReliableLog;
            this.resultReporter   = resultReporter;

            MessageDispatcher.AppName = context.CodePackageActivationContext.ApplicationTypeName;
        }