I´m currently developing a system which has the requirement to work asynchronous, so i decided it was time to give event driven architecture a go. Most of the functionality is CRUD
The different parts is:
- An UI which communicates with an API Gateway using a websocket connection
- The gateway receives the payload and creates a message with payload that goes into a Kafka cluster
- A service consumes the messages, validates and stores the entity in a database. An event is pushed to Kafka for consumption by the gateway and back to the UI
For create, update and delete its pretty straight forward.
However when it comes to retrieving data where i normally would use a HTTP GET call, stuff gets a little tricky. How can i properly retrieve this data? Do i create a request event, or what options do i have? The data in the database also needs to be "searchable" and "pageable" through the service - usually i would use a querystring for that. I find my "request data events" gettings pretty huge, and containing a lot of logic on what data is requested. Bacically the flow is the same right now as for create, update ect. where an event is pushed to Kafka containing information about what data that should be queried.
What is the correct way of handling data reads in an event driven way?
How do i property make my data searchable? (like get all resources which has a foreign key to resource x, or contains name = "xyz")