protected EventBatch ToBatch(List <DomainEvent> domainEvents) { EventBatch batch = new EventBatch(domainEvents.Count); foreach (DomainEvent domainEvent in domainEvents) { string eventBody = Serialization.Serialize(domainEvent); batch.AddEntry(domainEvent.GetType().AssemblyQualifiedName, eventBody); } return(batch); }
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); }