In the effort to redesign an asynchronous flow based functional 开发者_JAVA百科service to an event driven one, we have come up with changes on different part of this system. The service receives various statuses from external services through the API, which does computations and persists the result into the data store. The core logic is now moved from the api by introducing a queue (Kafka). Similarly the query functionality is provided through another interface (api) fronted by web UI. With this the command and query are separated. See below the diagram. I have few questions on the approach
- Is it right to have the
query API
(read) service & theevent-complete-handler
(write) operate on the same database with both dependent on the DB schema? Or is it better to have thequery-api
read from the replica DB? - The
core-business-logic
, at the end of computation, writes only to database and not to db+Kafka in a single transaction. Persisting to the database is handled by theevent-complete-handler
. Is this approach better? - Say in the future, if the
core-business-logic
needs to query the database to do the computation on every event, can it directly read from the database? Again, does it not create DB schema dependency between the services?
精彩评论