4 ms·
For your "maybe slightly better is" what happens when the db commit fails? FK constraint or some such, now you have sent an email (called the API) and have no r
by mustardo 4y ago
For your "maybe slightly better is" what happens when the db commit fails? FK constraint or some such, now you have sent an email (called the API) and have no record in your DB
Without two phase commits I would
1) Write to the DB in the original POST request a record indicating that an email should be sent
2) Process that record outside of the original request and mark it as sent
- cyco130 4y agoI assumed the job queue was on the same database so either both would succeed or both would fail. Your should_send_email flag effectively corresponds to my job queue.