Long transactions and remote calls
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
keep transactions short.
Planned topics
- A transaction holds a database connection and locks while it is open.
- Never call a payment API, email service, or any slow remote system inside it.
- A remote call cannot be rolled back with the database.
- Do remote work before or after the transaction, or use an event/outbox later (MID level).
- Long transactions starve the connection pool.
Draft outline details
Demonstration
a timeline: prepare (no transaction) → transaction: reserve stock, save order → commit → call payment/email.
Check your understanding
Why not call a payment API inside the transaction?
Show answer
It holds a connection and locks, and the payment cannot be rolled back.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.