↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

An Alternative to Outbox Pattern for Microservices Architecture

The article proposes a 2-phase message pattern as an alternative to Outbox for distributed transactions in microservices. It is based on DTM rather than a message queue, and it targets the dual-writes problem by making business execution and message submission atomic.

Reading notes
#

  • It illustrates an inter-bank transfer where one balance is increased and another is decreased, and explains that a crash between the two updates leaves the system inconsistent.
  • The 2-phase message uses DoAndSubmitDB to tie local business execution and message submission together, so both succeed or both fail.
  • If the process crashes after the local business update but before submission, DTM later calls a check-back URL to query whether the local transaction committed.
  • If the local transaction committed, DTM submits the global transaction and continues; if it rolled back, the global transaction fails and stops.
  • The article contrasts this with Outbox, which needs a local message table, polling or CDC, and message consumption.
  • It lists 2-phase message advantages as avoiding message queues, polling tasks, and message consumers, while supporting synchronous or asynchronous downstream calls.
  • It says the check-back mechanism uses a separate table keyed by gid, with inserted reasons such as COMMITTED and ROLLBACKED, to determine transaction state.
  • It also notes that a direct Submit call can replace the normal message pattern and support asynchronous work without a queue.