I'm trying to design an event-driven architecture based on Kafka for messaging but I'm struggling in managing event dependencies. Let's suppose the following service choreography:
- Service A: emits A-created
- Service B: emits B-created when processing A-created
- Service C: emits C-created when processing A-created and B-created
I have several times this situation, Service C that needs to join information from two events (A and B) to emit event C. This is quite complex in term of coding because it needs to be stateful processing since events can arrive in any order.
I don't understand if I'm reasoning in a wrong way or there is some particular suggestion in these cases. Every article I read about event-driven doesn't present such cases so I don't have a clear idea on how to approach this.