My service needs to publish external events to downstream systems. These external events are often fat ones, containing data from different aggregates. This basically can be achieved using stream-table join.
For example, I have a BusTripExecution aggregate publishing the ArrivedToCityStop(busTripExecutionId, busTripId, cityStopId) event.
I also have the following aggregates:
- CityStop aggregate containing information about the city stop - (cityStopId, street, city, country, number of awaiting passengers).
- BusTrip (busTripId, startingCityStopId, destinationStopId)
For external systems, I need to publish the enriched event ArrivedToCityStopEvent(_Enriched) with the information about the bus trip execution and latest city stop and bus trip info.
ArrivedToCityStopEvent { BusTripExecutionId, BusTripId, StartCityStop // taken from BusTrip joined with CityStop { Street, City, Country }, DestinationCityStop // taken from BusTrip joined with CityStop { Street, City, Country }, ArrivedToCityStop // taken from BusTrip joined with CityStop { Street, City, Country, AwaitingPassengers }
}
Basically we need to join BusTripExecution events with latest state of CityStop and BusTrip, a stream-table join.
To implement this in EventStore, I would imagine having a projection running inside its own catch-up subscription that subscribes to BusTrip & CityStop events, creates caches for each in read side storage and when handling the BusTripExecution events performs the enrichment.
Are there better solutions to implement this?
I have a few concerns with this solution:
- Performance, as same thread will be in charge of processing events for all the bus trip executions.
- Reusability. Other events coming from other aggregates might need to be enriched with the same data, or this data might be already built for query purposes.