public void FixtureSetUp() { FubuTransport.AllQueuesInMemory = true; runtime = FubuTransport.For <TestingJobRegistry>().StructureMap().Bootstrap(); history = runtime.Factory.Get <JobHistory>(); clock = runtime.Factory.Get <ISystemTime>().As <RewindableClock>(); theController = runtime.Factory.Get <IScheduledJobController>(); thePersistence = runtime.Factory.Get <ISchedulePersistence>(); theTimer = runtime.Factory.Get <IJobTimer>(); theController.Deactivate(); theTimer.ClearAll(); history.ClearAll(); theStartingTime = (DateTimeOffset)DateTime.Today.AddHours(8).ToUniversalTime(); theEndingTime = theStartingTime.AddSeconds(30); addTimes <Job1>(3); addTimes <Job2>(10); addTimes <Job3>(15); clock.Reset(theStartingTime.DateTime); theController.Activate(); theController.IsActive().ShouldBeTrue(); Thread.Sleep(32.Seconds()); theController.Deactivate(); }
protected override void beforeEach() { theExecution = new StubTimedExecution(); ClassUnderTest.LastExecution = new JobExecutionRecord(); MockFor <IScheduleRule>().Stub(x => x.ScheduleNextTime(now, ClassUnderTest.LastExecution)).Return(expected); theTimer = MockFor <IJobTimer>(); }
public ScheduledJobController( ScheduledJobGraph jobs, IJobTimer timer, IScheduleStatusMonitor statusMonitor, IServiceBus serviceBus, ILogger logger) { _jobs = jobs; _timer = timer; _statusMonitor = statusMonitor; _serviceBus = serviceBus; _logger = logger; }
public bool ShouldReschedule(DateTimeOffset now, IJobTimer timer) { var execution = timer.StatusFor(typeof(T)); if (execution == null) { return(true); } if (execution.Status == JobExecutionStatus.Scheduled) { return(false); } var age = now.Subtract(execution.ExpectedTime); return(age > MaximumTimeBeforeRescheduling); }