public RebuildIndex_EventToAggregateRootId_Job CreateJob(VersionRequestTimebox timebox)
        {
            job.Name = jobNameBuilder.GetJobName(job.Name);
            job.BuildInitialData(() => new RebuildIndex_JobData()
            {
                Timestamp = timebox.RequestStartAt
            });

            return(job);
        }
Esempio n. 2
0
        public void ShouldReturnJobNameWithPrefix()
        {
            var job = new TestJob();

            var result = _target.GetJobName(job);

            result.Should().NotBeNullOrEmpty();
            result.Should().BeEquivalentTo("Job.TestJob");
        }
Esempio n. 3
0
        /// <summary>
        ///   Start jobs.
        /// </summary>
        public void Start(bool telemetryRequired)
        {
            if (_scheduler != null)
            {
                _log.Debug(Resources.JobScheduler_Start_Scheduler_already_started);

                return;
            }

            _scheduler            = StdSchedulerFactory.GetDefaultScheduler();
            _scheduler.JobFactory = _jobFactory;

            var jobs = _schedulerJobTypesLoader.Load();

            var jobIndex = 0;

            foreach (var job in jobs.Where(job => !(job is ICustomScheduledJob)))
            {
                jobIndex++;

                var jobType = job.GetType();

                var scheduledJob = JobBuilder
                                   .Create(jobType)
                                   .WithIdentity(_jobNameBuilder.GetJobName(job))
                                   .Build();

                job.TelemetryRequired = telemetryRequired;

                var trigger = _triggerBuilder.CreateTrigger(job, jobIndex);

                _scheduler.ScheduleJob(scheduledJob, trigger);

                _log.Trace(Resources.JobScheduler_Start_Scheduled_job.FormatWith(jobType.FullName));
            }

            var initializers = _unityContainer.ResolveAll <ICustomJobInitializer>();

            foreach (var customJobInitializer in initializers)
            {
                customJobInitializer.Initialize(_scheduler);
            }

            _scheduler.Start();

            _log.Trace(Resources.JobScheduler_Start_Scheduler_started);
        }