public Worker(IErrorTracker errorTracker, IReceiveMessages receiveMessages, IActivateHandlers activateHandlers, IStoreSubscriptions storeSubscriptions, ISerializeMessages serializeMessages, IStoreSagaData storeSagaData, IInspectHandlerPipeline inspectHandlerPipeline, string workerThreadName, IHandleDeferredMessage handleDeferredMessage, IMutateIncomingMessages mutateIncomingMessages, IStoreTimeouts storeTimeouts, IEnumerable <IUnitOfWorkManager> unitOfWorkManagers, ConfigureAdditionalBehavior configureAdditionalBehavior, MessageLogger messageLogger) { this.receiveMessages = receiveMessages; this.serializeMessages = serializeMessages; this.mutateIncomingMessages = mutateIncomingMessages; this.unitOfWorkManagers = unitOfWorkManagers; this.configureAdditionalBehavior = configureAdditionalBehavior; this.messageLogger = messageLogger; this.errorTracker = errorTracker; dispatcher = new Dispatcher(storeSagaData, activateHandlers, storeSubscriptions, inspectHandlerPipeline, handleDeferredMessage, storeTimeouts); dispatcher.UncorrelatedMessage += RaiseUncorrelatedMessage; nullMessageReceivedBackoffHelper = CreateBackoffHelper(configureAdditionalBehavior.BackoffBehavior); workerThread = new Thread(MainLoop) { Name = workerThreadName }; workerThread.Start(); log.Info("Worker {0} created and inner thread started", WorkerThreadName); }
public void WaitsForAsLongAsTheGivenBackoffTimesSpecify() { var timesWaited = new List<TimeSpan>(); var backoffTimes = new [] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(3), }; var helper = new BackoffHelper(backoffTimes) { waitAction = timesWaited.Add }; helper.Wait(); helper.Wait(); helper.Wait(); timesWaited.Count.ShouldBe(3); timesWaited[0].ShouldBe(TimeSpan.FromSeconds(1)); timesWaited[1].ShouldBe(TimeSpan.FromSeconds(2)); timesWaited[2].ShouldBe(TimeSpan.FromSeconds(3)); }
public void KeepsWaitingForAsLongAsTheLastTimeSpanSpecifies() { var timesWaited = new List<TimeSpan>(); var backoffTimes = new [] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), }; var helper = new BackoffHelper(backoffTimes) { waitAction = timesWaited.Add }; helper.Wait(); helper.Wait(); helper.Wait(); helper.Wait(); helper.Wait(); timesWaited.Count.ShouldBe(5); timesWaited[2].ShouldBe(TimeSpan.FromSeconds(2)); timesWaited[3].ShouldBe(TimeSpan.FromSeconds(2)); timesWaited[4].ShouldBe(TimeSpan.FromSeconds(2)); }
public Worker( IErrorTracker errorTracker, IReceiveMessages receiveMessages, IActivateHandlers activateHandlers, IStoreSubscriptions storeSubscriptions, ISerializeMessages serializeMessages, IStoreSagaData storeSagaData, IInspectHandlerPipeline inspectHandlerPipeline, string workerThreadName, IHandleDeferredMessage handleDeferredMessage, IMutateIncomingMessages mutateIncomingMessages, IStoreTimeouts storeTimeouts, IEnumerable<IUnitOfWorkManager> unitOfWorkManagers, ConfigureAdditionalBehavior configureAdditionalBehavior, MessageLogger messageLogger, RebusSynchronizationContext continuations) { this.receiveMessages = receiveMessages; this.serializeMessages = serializeMessages; this.mutateIncomingMessages = mutateIncomingMessages; this.unitOfWorkManagers = unitOfWorkManagers; this.configureAdditionalBehavior = configureAdditionalBehavior; this.messageLogger = messageLogger; this.continuations = continuations; this.errorTracker = errorTracker; dispatcher = new Dispatcher(storeSagaData, activateHandlers, storeSubscriptions, inspectHandlerPipeline, handleDeferredMessage, storeTimeouts); dispatcher.UncorrelatedMessage += RaiseUncorrelatedMessage; nullMessageReceivedBackoffHelper = CreateBackoffHelper(configureAdditionalBehavior.BackoffBehavior); workerThread = new Thread(MainLoop) { Name = workerThreadName }; workerThread.Start(); log.Info("Worker {0} created and inner thread started", WorkerThreadName); }
public void CanBeReset() { var timesWaited = new List<TimeSpan>(); var backoffTimes = new[] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), }; var helper = new BackoffHelper(backoffTimes) { waitAction = timesWaited.Add }; helper.Wait(); helper.Wait(); helper.Reset(); helper.Wait(); helper.Wait(); timesWaited.Count.ShouldBe(4); timesWaited[0].ShouldBe(TimeSpan.FromSeconds(1)); timesWaited[1].ShouldBe(TimeSpan.FromSeconds(2)); timesWaited[2].ShouldBe(TimeSpan.FromSeconds(1)); timesWaited[3].ShouldBe(TimeSpan.FromSeconds(2)); }