private bool Execute(Tick <TJob, TIdentity> tick)
        {
            var now = Context.System.Scheduler.Now.UtcDateTime;

            foreach (var schedule in State.Entries.Values.Where(e => ShouldTriggerSchedule(e, now)))
            {
                _jobDefinitionService.Load(schedule.Job.GetType());
                var jobDefinition = _jobDefinitionService.GetDefinition(schedule.Job.GetType());
                Log.Info("JobScheduler for Job of Name={0}; sending job of Definition={1} to JobRunner.", Name,
                         jobDefinition);

                var manager = Context.ActorSelection(Context.Parent.Path.Parent);
                manager.Tell(schedule.Job, ActorRefs.NoSender);

                Emit(new Finished <TJob, TIdentity>(schedule.JobId, now), ApplySchedulerEvent);

                var next = schedule.WithNextTriggerDate(now);
                if (next != null)
                {
                    Emit(new Scheduled <TJob, TIdentity>(next), ApplySchedulerEvent);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public Task BootAsync(CancellationToken cancellationToken)
        {
            _commandDefinitionService.Load(_loadedVersionedTypes.Commands);
            _eventDefinitionService.Load(_loadedVersionedTypes.Events);
            _jobDefinitionService.Load(_loadedVersionedTypes.Jobs);

            return(Task.FromResult(0));
        }