Let's assume the following architecture where
EventCreatorApp
creates anEvent
which is logged to DB and sent toWorkerApp
for processingWorkerApp
processes the event, handles failures, etc.
EventCreatorApp --> [ DB ]
|
---------> WorkerApp
Once WorkerApp
is done, I want to update the event row in the DB with the outcome of running that event.
My question: Which app should write the outcome to the database?
If WorkerApp
writes the outcome to the db the logic is nicely decoupled (one app creates events, one app executes events) but I have two apps writing to the db. What's worst, I want to deploy WorkerApp
on an AWS Lambda, and that would mean opening a new connection to the db for each event processed.
If EventCreatorApp
writes the outcome to the db I don't have any db access problems, but it feels like I'm pushing into EventCreatorApp
some logic that doesn't really belong there, and in general I'm coupling the two apps a bit since EventCreatorApp
would have to wait for a response.
Which solution is best?