Package outbox.spi
Interface TxContext
- All Known Implementing Classes:
SpringTxContext,ThreadLocalTxContext
public interface TxContext
Abstracts the transaction lifecycle so outbox operations can participate in
the caller's transaction without depending on a specific transaction manager.
Implementations: ThreadLocalTxContext (manual JDBC),
outbox.spring.SpringTxContext (Spring-managed).
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidafterCommit(Runnable callback) Registers a callback to run after the current transaction commits.voidafterRollback(Runnable callback) Registers a callback to run after the current transaction rolls back.Returns the JDBC connection bound to the current transaction.booleanReturnstrueif a transaction is currently active on this thread.
-
Method Details
-
isTransactionActive
boolean isTransactionActive()Returnstrueif a transaction is currently active on this thread. -
currentConnection
Connection currentConnection()Returns the JDBC connection bound to the current transaction.- Throws:
IllegalStateException- if no transaction is active
-
afterCommit
Registers a callback to run after the current transaction commits.- Parameters:
callback- action to execute post-commit- Throws:
IllegalStateException- if no transaction is active
-
afterRollback
Registers a callback to run after the current transaction rolls back.- Parameters:
callback- action to execute post-rollback- Throws:
IllegalStateException- if no transaction is active
-