DueTimeoutsResult GetDueTimeouts() { try { return(storeTimeouts.GetDueTimeouts()); } catch (Exception exception) { throw new ApplicationException("Could not retrieve due timeouts!", exception); } }
public void DoesNotActuallyRemoveTimeoutUntilItIsMarkedAsProcessed() { // arrange const string someRecognizablePieceOfCustomData = "this custom dizzle can be recognizzle!!"; var actualTimeWhenIWroteThis = new DateTime(2012, 11, 30, 22, 13, 00, DateTimeKind.Utc); storage.Add(new Rebus.Timeout.Timeout("someone", "wham!", actualTimeWhenIWroteThis.AddSeconds(20), Guid.Empty, someRecognizablePieceOfCustomData)); TimeMachine.FixTo(actualTimeWhenIWroteThis.AddSeconds(25)); // act List <DueTimeout> dueTimeoutsFromFirstCall; using (var dueTimeoutsResult = storage.GetDueTimeouts()) { dueTimeoutsFromFirstCall = dueTimeoutsResult.DueTimeouts.ToList(); } // this is where we'd have marked the due timeout as processed - instead, we pretend that didn't happen // (perhaps because the timeout service was interrupted) ... List <DueTimeout> dueTimeoutsFromSecondCall; using (var nextDueTimeoutsResult = storage.GetDueTimeouts()) { dueTimeoutsFromSecondCall = nextDueTimeoutsResult.DueTimeouts.ToList(); } // assert dueTimeoutsFromFirstCall.Count.ShouldBe(1); dueTimeoutsFromFirstCall.Single().CustomData.ShouldBe(someRecognizablePieceOfCustomData); dueTimeoutsFromSecondCall.Count().ShouldBe(1); dueTimeoutsFromSecondCall.Single().CustomData.ShouldBe(someRecognizablePieceOfCustomData); }
void CheckCallbacks(object sender, ElapsedEventArgs e) { if (currentlyChecking) { return; } lock (checkLock) { if (currentlyChecking) { return; } try { currentlyChecking = true; var dueTimeouts = storeTimeouts.GetDueTimeouts().ToList(); if (!dueTimeouts.Any()) { return; } log.Info("Got {0} dues timeouts - will send them now", dueTimeouts.Count); foreach (var timeout in dueTimeouts) { log.Info("Timeout!: {0} -> {1}", timeout.CorrelationId, timeout.ReplyTo); var sagaId = timeout.SagaId; var reply = new TimeoutReply { SagaId = sagaId, CorrelationId = timeout.CorrelationId, DueTime = timeout.TimeToReturn, CustomData = timeout.CustomData, }; handleDeferredMessage.SendReply(timeout.ReplyTo, reply, sagaId); timeout.MarkAsProcessed(); } } finally { currentlyChecking = false; } } }
DueTimeoutsResult IStoreTimeouts.GetDueTimeouts() { return(new DueTimeoutsResult(_oldTimeoutStorage.GetDueTimeouts().DueTimeouts.Union(_newTimeoutStorage.GetDueTimeouts().DueTimeouts))); }