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 Type
    Method
    Description
    void
    Registers a callback to run after the current transaction commits.
    void
    Registers a callback to run after the current transaction rolls back.
    Returns the JDBC connection bound to the current transaction.
    boolean
    Returns true if a transaction is currently active on this thread.
  • Method Details

    • isTransactionActive

      boolean isTransactionActive()
      Returns true if 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

      void afterCommit(Runnable callback)
      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

      void afterRollback(Runnable callback)
      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