public void TestWriteRead()
        {
            EventJournal journal = EventJournal.Open("test");

            journal.Write("name123", 1, EventBatch.Of("type1", "type1_instance1"));
            journal.Write("name456", 1, EventBatch.Of("type2", "type2_instance1"));
            EventJournalReader reader = journal.Reader("test_reader");

            Assert.AreEqual(new StoredEvent(0, new EventValue("name123", 1, "type1", "type1_instance1", "")), reader.ReadNext());
            reader.Acknowledge(0);
            Assert.AreEqual(new StoredEvent(1, new EventValue("name456", 1, "type2", "type2_instance1", "")), reader.ReadNext());
            reader.Acknowledge(1);
            Assert.AreEqual(new StoredEvent(-1, new EventValue("", -1, "", "", "")), reader.ReadNext());

            journal.Close();
        }
        internal void DispatchEach()
        {
            while (!closed)
            {
                StoredEvent storedEvent = reader.ReadNext();

                if (storedEvent.IsValid())
                {
                    Message message =
                        new Message(
                            Convert.ToString(storedEvent.Id),
                            storedEvent.EventValue.Type,
                            storedEvent.EventValue.Body);

                    topic.Publish(message);

                    reader.Acknowledge(storedEvent.Id);
                }
                else
                {
                    Thread.Sleep(100);
                }
            }
        }