示例#1
0
        public void TestEventJournalPublisher()
        {
            EventJournal          eventJournal     = EventJournal.Open("test-ej");
            MessageBus            messageBus       = MessageBus.Start("test-bus");
            Topic                 topic            = messageBus.OpenTopic("test-topic");
            EventJournalPublisher journalPublisher =
                EventJournalPublisher.From(eventJournal.Name, messageBus.Name, topic.Name);

            EventJournalPublisherTestSubscriber subscriber = new EventJournalPublisherTestSubscriber();

            topic.Subscribe(subscriber);

            for (int idx = 0; idx < 3; ++idx)
            {
                eventJournal.Write("test1", idx, "test1type", "test1instance" + idx);
            }

            for (int idx = 0; idx < 3; ++idx)
            {
                eventJournal.Write("test2", idx, "test2type", "test2instance" + idx);
            }

            subscriber.WaitForExpectedMessages(6);

            topic.Close();

            journalPublisher.Close();

            Assert.AreEqual(6, subscriber.handledMessages.Count);
        }
        public void TestEventJournalPublisher()
        {
            EventJournal          eventJournal     = EventJournal.Open("test-ej");
            MessageBus            messageBus       = MessageBus.Start("test-bus");
            Topic                 topic            = messageBus.OpenTopic("test-topic");
            EventJournalPublisher journalPublisher =
                EventJournalPublisher.From(eventJournal.Name, messageBus.Name, topic.Name);

            EventJournalPublisherTestSubscriber subscriber = new EventJournalPublisherTestSubscriber();

            topic.Subscribe(subscriber);

            EventBatch batch1 = new EventBatch();

            for (int idx = 0; idx < 3; ++idx)
            {
                batch1.AddEntry("test1type", "test1instance" + idx);
            }
            eventJournal.Write("test1", 0, batch1);

            EventBatch batch2 = new EventBatch();

            for (int idx = 0; idx < 3; ++idx)
            {
                batch2.AddEntry("test2type", "test2instance" + idx);
            }
            eventJournal.Write("test2", 0, batch2);

            subscriber.WaitForExpectedMessages(6);

            topic.Close();

            journalPublisher.Close();

            subscriber.handledMessages.Count.Should().Be(6);
        }