Пример #1
0
        public void Start(string ravenInstanceId)
        {
            Trace("Starting Errordite service {0} for raven instance:={1}", _serviceConfiguration.Service, ravenInstanceId);

            //receive service runs a thread per organisation, polling every org's queue
            //other services just have a single thread processing the queue
            if (_serviceConfiguration.Service == Service.Receive)
            {
                IEnumerable<Organisation> organisations;
                using (ObjectFactory.Container.Kernel.BeginScope())
                {
                    using (var session = ObjectFactory.GetObject<IAppSession>())
                    {
                        organisations = session.MasterRaven
                            .Query<OrganisationDocument, Organisations>()
                            .Where(o => o.RavenInstanceId == RavenInstance.GetId(ravenInstanceId))
							.As<Organisation>()
                            .ToList();
                    }
                }

                foreach (var organisation in organisations)
                {
                    AddProcessor(organisation.FriendlyId, null);
                }
            }
            else
            {
                for (int i = 0; i < _serviceConfiguration.ServiceProcessorCount; i++)
                {
                    AddProcessor(null, ravenInstanceId);
                }
            }

            Trace("Started Errordite service {0} for raven instance:={1}", _serviceConfiguration.Service, ravenInstanceId);
        }