
▲ 18 r/scala
https://rockthejvm.com/articles/never-call-apis-inside-database-transactions
I wrote this after seeing how easy it is to make this mistake in otherwise clean backend code. The core issue is that your DB transaction can roll back database writes, but it cannot roll back an HTTP call that already happened; payment, shipping, inventory reservation, fraud check, etc. The article walks through a practical implementation using Transactional Outbox, Result Table, and Saga Compensation with Scala 3 / Slick / PostgreSQL / Play / Pekko. Curious how others usually handle this pattern in production - outbox worker, message broker, workflow engine, or something else?
u/Material_Big9505 — 17 days ago