コード例 #1
0
        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);
        }
コード例 #2
0
        public void DoesNotComplainWhenTheSameTimeoutIsAddedMultipleTimes()
        {
            var justSomeTime = new DateTime(2010, 1, 1, 10, 30, 0, DateTimeKind.Utc);

            storage.Add(new Timeout.Timeout {
                CorrelationId = "blah", ReplyTo = "blah blah", TimeToReturn = justSomeTime
            });
            storage.Add(new Timeout.Timeout {
                CorrelationId = "blah", ReplyTo = "blah blah", TimeToReturn = justSomeTime
            });
            storage.Add(new Timeout.Timeout {
                CorrelationId = "blah", ReplyTo = "blah blah", TimeToReturn = justSomeTime
            });
        }
コード例 #3
0
        public void Handle(TimeoutRequest message)
        {
            var currentMessageContext = MessageContext.GetCurrent();

            var newTimeout = new Timeout
            {
                SagaId        = message.SagaId,
                CorrelationId = message.CorrelationId,
                ReplyTo       = currentMessageContext.ReturnAddress,
                TimeToReturn  = Time.Now() + message.Timeout,
                CustomData    = message.CustomData,
            };

            storeTimeouts.Add(newTimeout);

            log.Info("Added new timeout: {0}", newTimeout);
        }
コード例 #4
0
        public void Handle(TimeoutRequest message)
        {
            var currentMessageContext = MessageContext.GetCurrent();

            if (string.IsNullOrWhiteSpace(currentMessageContext.ReturnAddress))
            {
                throw new InvalidOperationException("TimeoutRequest received with no ReturnAddress header set. No way to return message when timeout elapses.");
            }

            var newTimeout = new Timeout.Timeout(currentMessageContext.ReturnAddress,
                                                 message.CorrelationId,
                                                 RebusTimeMachine.Now() + message.Timeout,
                                                 message.SagaId,
                                                 message.CustomData);

            storeTimeouts.Add(newTimeout);

            log.Info("Added new timeout: {0}", newTimeout);
        }
コード例 #5
0
 public void Add(Timeout newTimeout)
 {
     // New insertions will always be persisted under the new IStoreTimeouts
     _newTimeoutStorage.Add(newTimeout);
 }