After my team went all-out on the microservice paradigm with an emphasis on message passing, I'm having trouble defining and keeping track of all the events in the system.
I've read some guides on the event-driven architecture, and while I get that the messages themselves should be as simple as possible, it still leaves the question of defining their data model open. I'm guessing the publisher should define the properties of a message, but is there a way to ensure type safety in the consumers, similar to Protobuf?
What about keeping track of all of the possible events in the system? Sometimes I'm exploring a repo and there is no way for me to know which service produces a certain event, or if it is even being used any more.
Is there a solution for this broad problem, and what would be the best practises when defining such models? I've heard of people using Apache Avro for the type safety but integrating it would not solve all of the above mentioned issues.
class
orstruct
) to define messages as plain DTO types in separate shared, versioned libraries/packages (shared between whichever subsystems/processes send or receive them) and treat those as the source of truth concerning what shape and structure each message needs to have.