Hi!
I created a lagom service with 2 persistent entities. The service is called AuthzService and manages the PersistentEntities PRoleEntity and PGroupEntity. I now get 2 persistent event streams and i thought that it may be a nice idea to expose only 1 public AuthZEvent-Stream via Kafka - with both streams of role & group merged.
My question is now how i can merge these 2 streams. The current code (handling only PRoleEvent) is:
public Topic<AuthzEvent> roleEvents() {
return TopicProducer.taggedStreamWithOffset(PRoleEvent.TAG.allTags(),
(tag, offset) -> registry.eventStream(tag, offset)
.mapAsync(1, eventAndOffset ->
convertEvent(eventAndOffset.first())
.thenApply(event -> Pair.create(event, eventAndOffset.second()))));
}
…but obviously this only handles events of the PRole-Stream…
greetigs,
Michael