feat: migrate OutboxStore from Exposed to plain JDBC (KOJAK-64)#26
Open
feat: migrate OutboxStore from Exposed to plain JDBC (KOJAK-64)#26
Conversation
Replace Exposed ORM with plain JDBC in PostgresOutboxStore and MysqlOutboxStore. This eliminates the coupling to Exposed's transaction mechanism, allowing okapi to work transparently with any Spring PlatformTransactionManager — JPA/Hibernate, JDBC, jOOQ, MyBatis, etc. Key changes: - Add ConnectionProvider interface to okapi-core - Add SpringConnectionProvider using DataSourceUtils.getConnection() - Rewrite PostgresOutboxStore and MysqlOutboxStore to plain JDBC - Remove Exposed dependencies from okapi-postgres and okapi-mysql - Delete OutboxTable.kt from both modules - Add TransactionRunner to OutboxPurger (fixes connection leak) - Fix null parameter handling (setNull instead of setTimestamp(null)) - Parameterize status in removeDeliveredBefore SQL - Change spring-jdbc from compileOnly to implementation
Move ExposedTransactionContextValidator out of okapi-core into a dedicated okapi-exposed module. Add ExposedConnectionProvider and ExposedTransactionRunner for Ktor/standalone Exposed apps. okapi-core is now free of Exposed dependencies — only plain JDK types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PostgresOutboxStoreandMysqlOutboxStorewith plain JDBC via newConnectionProviderfun interfaceSpringConnectionProvider(usesDataSourceUtils.getConnection()) for seamless Spring integration with anyPlatformTransactionManager(JPA, JDBC, jOOQ, MyBatis)OutboxTableExposed table definitions from both postgres and mysql modulesokapi-postgres,okapi-mysql, andokapi-spring-bootMotivation
Exposed as an internal implementation detail of OutboxStore forced consumers to:
compileOnlyin okapi leaked at runtime)SpringTransactionManagerinstead of standard Spring TMsJpaFlushingTransactionManagerfor JPA coexistenceWith
ConnectionProvider, okapi borrows the JDBC connection from whatever transaction mechanism the app uses — zero coupling.Key changes
okapi-coreConnectionProviderfun interfaceokapi-postgresPostgresOutboxStore(connectionProvider, clock)— pure JDBCokapi-mysqlMysqlOutboxStore(connectionProvider, clock)— pure JDBCokapi-spring-bootSpringConnectionProvider(dataSource)auto-configuredokapi-spring-bootOutboxPurgernow takes optionalTransactionRunnerokapi-integration-testsJdbcConnectionProvidertest helper, updated all testsValidated by
5 standalone example apps (JPA, JDBC, multi-datasource, jOOQ, Ktor+Exposed) — all passing JUnit tests and smoke tests against this branch.
Test plan
./gradlew test)