Hello,
I’m trying to compose some projection based on stream of events from the event store.
In most cases the entry point, the insert, is clear and one event is responsible for it and all of the data that should be projected is ahead of it.
However sometimes i have data that has happened in the past and should be replicated across multiple projected documents.
Let me clarify by an example.
in order:
UserCreated(user_id,username)
WalletCreated(id,user_id)
The user service is not aware of wallet service.
They live on totally separate networks/devices, they have separate repositories.
I would like to know what is the username of owner of specific wallet, i could do that in few ways:
First, the user can provide query of username for specific id, since the wallet service knows an id of an user, i could dispatch two queries with axon, first would grab the wallet and second one would grab the username and return composed response.
This one looks handy at first but it has some problems, firstly i still want to get an username even if the user service becomes unavailable, secondly it’s two queries (performance )
Second approach would be to create ‘book keeping’ repository inside the wallet projection that would record the usernames and the query would join two collections on the request just like the first approach but the joining would occur directly inside wallet service.
Third approach, similar to the previous one with one slight difference: the joining occurs on the projection. Since the wallet projection entry point knows an user id it can lookup the username immediately and save it in it’s own document so whenever query comes, it has all the data required.
Are there any other approaches to these kind of problems? Would really appreciate any points on that, because from my current understanding there is no clean way around that if i want to keep the projection of the second service unaffected by the first one, however i’m still thinking what would be the most performant solution for that.