コード例 #1
0
        protected EventJournalPublisher(
            string eventJournalName,
            string messageBusName,
            string topicName)
        {
            this.reader           = EventJournal.Open(eventJournalName).Reader("topic-" + topicName + "-reader");
            this.topic            = MessageBus.Start(messageBusName).OpenTopic(topicName);
            this.dispatcherThread = new Thread(new ThreadStart(this.DispatchEach));

            StartDispatcherThread();
        }
コード例 #2
0
        public EventJournalReader Reader(string name)
        {
            if (readers.ContainsKey(name))
            {
                return(readers[name]);
            }

            EventJournalReader reader = new EventJournalReader(name, this);

            readers.Add(name, reader);

            return(reader);
        }
コード例 #3
0
        public void TestOpenEventJournalReader()
        {
            EventJournal       journal = EventJournal.Open("test");
            EventJournalReader reader  = journal.Reader("test_reader");

            Assert.IsNotNull(reader);
            Assert.AreEqual("test_reader", reader.Name);
            EventJournalReader readerPreOpened = journal.Reader("test_reader");

            Assert.AreSame(reader, readerPreOpened);

            journal.Close();
        }
コード例 #4
0
        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();
        }