Package outbox.jdbc
Class JdbcTransactionManager
java.lang.Object
outbox.jdbc.JdbcTransactionManager
Lightweight transaction manager for manual JDBC usage. Obtains a connection,
disables auto-commit, and binds it to a
ThreadLocalTxContext.
Use via try-with-resources on the returned JdbcTransactionManager.Transaction:
try (var tx = txManager.begin()) {
writer.write(event);
tx.commit();
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAn active transaction handle. -
Constructor Summary
ConstructorsConstructorDescriptionJdbcTransactionManager(ConnectionProvider connectionProvider, ThreadLocalTxContext txContext) -
Method Summary
Modifier and TypeMethodDescriptionbegin()Begins a new transaction by obtaining a connection and binding it to the thread context.
-
Constructor Details
-
JdbcTransactionManager
public JdbcTransactionManager(ConnectionProvider connectionProvider, ThreadLocalTxContext txContext)
-
-
Method Details
-
begin
Begins a new transaction by obtaining a connection and binding it to the thread context.- Returns:
- a new
JdbcTransactionManager.Transactionhandle (use with try-with-resources) - Throws:
SQLException- if a connection cannot be obtained
-