public void can_add_duplicate()
 {
     var id = Guid.NewGuid();
     var cache = new OutstandingMessageCache();
     cache.StartMessage(new OutstandingMessage(id, null, Helper.BuildFakeEvent(id, "type", "name", 0), 0), DateTime.Now);
     cache.StartMessage(new OutstandingMessage(id, null, Helper.BuildFakeEvent(id, "type", "name", 0), 0), DateTime.Now);
     Assert.AreEqual(1, cache.Count);
     Assert.AreEqual(0, cache.GetLowestPosition());
 }
 public void lowest_works_on_adds_then_remove()
 {
     var id = Guid.NewGuid();
     var id2 = Guid.NewGuid();
     var id3 = Guid.NewGuid();
     var cache = new OutstandingMessageCache();
     cache.StartMessage(new OutstandingMessage(id, null, Helper.BuildFakeEvent(id, "type", "name", 10), 0), DateTime.Now);
     cache.StartMessage(new OutstandingMessage(id2, null, Helper.BuildFakeEvent(id2, "type", "name", 11), 0), DateTime.Now);
     cache.StartMessage(new OutstandingMessage(id3, null, Helper.BuildFakeEvent(id3, "type", "name", 12), 0), DateTime.Now);
     cache.Remove(id);
     Assert.AreEqual(11, cache.GetLowestPosition());
 }
 public void can_remove_existing_item()
 {
     var id = Guid.NewGuid();
     var cache = new OutstandingMessageCache();
     cache.StartMessage(new OutstandingMessage(id, null, Helper.BuildFakeEvent(id, "type", "name", 0), 0), DateTime.Now);
     cache.Remove(id);
     Assert.AreEqual(0, cache.Count);
 }
        private void StartMessage(OutstandingMessage message, DateTime expires)
        {
            var result = _outstandingMessages.StartMessage(message, expires);

            if (result == StartMessageResult.SkippedDuplicate)
            {
                Log.Warn("Skipping message {stream}/{eventNumber} with duplicate eventId {eventId}",
                         message.ResolvedEvent.OriginalStreamId,
                         message.ResolvedEvent.OriginalEventNumber,
                         message.EventId);
            }
        }
 public void message_that_expires_is_included_in_expired_list()
 {
     var id = Guid.NewGuid();
     var cache = new OutstandingMessageCache();
     cache.StartMessage(new OutstandingMessage(id, null, Helper.BuildFakeEvent(id, "type", "name", 0), 0), DateTime.Now.AddSeconds(-1));
     var expired = cache.GetMessagesExpiringBefore(DateTime.Now).ToList();
     Assert.AreEqual(1, expired.Count());
     Assert.AreEqual(id, expired.FirstOrDefault().EventId);
 }
Esempio n. 6
0
 private void MarkBeginProcessing(OutstandingMessage message)
 {
     _statistics.IncrementProcessed();
     _outstandingMessages.StartMessage(message, DateTime.Now + _settings.MessageTimeout);
 }