コード例 #1
0
        /// <summary>
        /// This override sends the service start message.
        /// </summary>
        protected override void StartInternal()
        {
            //This method starts the components in the service in the correct order.
            try
            {
                mEventsWrapper.OnStartRequested();

                //This method initialises the configuration.
                EventStart(() => ConfigurationInitialise(), "Configuration");

                //This initialises the process loop.
                EventStart(() => CoreEngineInitialize(), "Core Engine Initialization");

                //This method initialises the serialization container.
                EventStart(() => ServiceStart(mServiceHandlers), "Service Handlers Container");

                //Start data collection.
                EventStart(() => ServiceStart(mDataCollection), "Data Collection");

                //OK, register the resource tracker
                EventStart(() => ServiceStart(mResourceMonitor), "Resource Tracker");

                //This method connects any components that require Shared Service together before they start.
                EventStart(() => mCommands.SharedServicesConnect(), "Command Shared Services");

                //Ensure that the communication handler is working.
                EventStart(() => ServiceStart(mCommunication), "Communication Container");

                //Start the senders
                EventStart(() => mCommunication.SendersStart(), "Communication Senders");

                //Ensure that any handlers are registered.
                EventStart(() => ServiceStart(mCommands), "Commands Container");

                //OK, start the loop to start processing requests and picking up messages from the listeners.
                EventStart(() => TaskManagerStart(), "Task Manager");

                //Finally register the housekeeping schedules.
                EventStart(() => SchedulesRegister(), "Scheduler");

                //OK start the commands in parallel at the same priority group.
                EventStart(() => mCommands.CommandsStart(ServiceStart), "Commands");

                //Now start the listeners and deadletter listeners
                EventStart(() => mCommunication.ListenersStart(), "Communication Listeners");

                //OK start the commands in parallel at the same priority group.
                EventStart(() => Dispatch = new DispatchWrapper(mServiceHandlers, mTaskManager.ExecuteOrEnqueue, () => Status
                                                                , Policies.TaskManager.TransmissionPayloadTraceEnabled)
                           , "Dispatch Wrapper");

                //Signal that start has completed.
                mEventsWrapper.OnStartCompleted();

                //Do a final log now that everything has started up.
                LogStatistics().Wait(TimeSpan.FromSeconds(1));
            }
            catch (Exception ex)
            {
                try
                {
                    //Throw the original exception.
                    mDataCollection?.LogException("StartInternal unhandled exception thrown - service is stopping", ex);
                    //Just try and tidy up where possible.
                    StopInternal();
                }
                catch (Exception)
                {
                    // Nothing do be done here
                }

                //Throw the original exception out to the initiating party
                throw ex;
            }
        }