private void ConsumeMessage() { while (!_stopConsuming) { var @event = _db.GetNextEvent(_topic); if (@event == null) { return; } switch (@event.EventType) { case EventType.TentativeMessage: PublishAndAddTentativeMessage(@event.Message); break; case EventType.AddSubscriber: AddSubscriber(@event.Subscriber); break; case EventType.ComittedMessages: PublishCommittedMessages(@event.Messages); break; case EventType.TentativeMessages: PublishAndAddTentativeMessages(@event.Messages); break; case EventType.ComittedMessage: PublishCommittedMessage(@event.Message); break; case EventType.AddSubscribers: AddSubScribers(@event.Subscribers); break; default: throw new ArgumentException(@event.EventType + " Not supported"); } _db.EventHasBeenhandled(_topic, @event.Id); } }