Accepted
Applications often need a domain change and an outbox message to commit atomically. Emitting to a broker before a database transaction commits can publish messages for data that later rolls back.
CAP supports transactional outbox persistence through savePublish(event,
ctx?), where the operation context may carry an adapter-specific transaction
object. savePublishWithTx(event, tx) remains deprecated compatibility only.
When a transaction is provided but the publisher cannot participate in that
transaction, CAP should defer immediate emission and leave the outbox row for
post-commit publication by the scheduler or application-level post-commit
handling.
publish(..., { tx }) defers broker emission by default; immediate: true
is explicit and non-atomic.withTransactionAndPostCommit for explicit post-commit
send workflows.