Skip to content
Exposed docs2.0

Exposed Batch R2DBC Adapter

Latest stable Based on Exposed release 2.0.0

A suspendable R2DBC repository, keyset reader, and batch writer for batch-core.

Reactive applications need durable batch state without importing JDBC classes. This artifact owns its R2DBC table and mapping definitions.

Choose it when the application owns an R2dbcDatabase, pool, and suspend transaction lifecycle. Use the JDBC artifact for blocking Exposed transactions.

dependencies {
implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<version>"))
implementation("io.github.bluetape4k.exposed:bluetape4k-exposed-batch-r2dbc")
runtimeOnly("io.github.bluetape4k:bluetape4k-jackson3")
}

ExposedR2dbcBatchJobRepository applies owner/version CAS inside one suspendTransaction. The R2DBC tables and mappers intentionally do not reuse a JDBC package.

Create the application-owned R2dbcDatabase, create the batch tables, choose CheckpointJson.jackson3() or a custom serializer, and run the core runner in a suspend scope.

  • Use ExposedR2dbcBatchJobRepository for durable suspendable state.
  • Use ExposedR2dbcBatchReader for keyset pages and checkpoint restore.
  • Use ExposedR2dbcBatchWriter for suspendable batch writes.

Keep suspend database work outside non-suspending memory locks, preserve stable reader ordering, and make writer effects idempotent.

The adapter depends on batch-core, Exposed R2DBC, and Bluetape coroutine/R2DBC utilities. It has no production dependency on the JDBC adapter.

Configure the R2DBC pool, dialect, page size, and dispatcher. The application owns database creation, transaction composition, metrics, and shutdown.

Replace the former aggregator dependency with batch-core plus this adapter and keep versions supplied by the ecosystem BOM. New code imports the public io.bluetape4k.batch.CheckpointJson; the deprecated io.bluetape4k.batch.internal.CheckpointJson constructor and mapper overloads remain only as JVM compatibility bridges. Custom repositories must implement saveCheckpointAndReturn so owner/version CAS is retained. Add the optional bluetape4k-jackson3 runtime for CheckpointJson.jackson3(), or inject a custom serializer with an explicit allowlist.

Run the compatibility fixtures from the repository root:

Terminal window
bash scripts/batch/validate_consumer_fixtures.sh

The gate covers aggregator-runtime, core-custom-json, jdbc-runtime, r2dbc-jackson3-runtime, legacy-binary-runtime, and the Maven JDBC consumer.

Wrong owner, stale version, unclaimed execution, and zero-row CAS updates fail closed. Cancellation is not converted into a normal failure. After a committed chunk, a later FAILED step keeps the last checkpoint. A null failure report checkpoint is treated as no replacement, so the R2DBC completion update does not erase the stored value and restart can resume after that key.

Observe suspend transaction latency, lease expiry, CAS conflicts, checkpoint size, and driver errors. Keep schema creation and migration outside the adapter.

Run ./gradlew :bluetape4k-exposed-batch-r2dbc:test sequentially for H2, PostgreSQL, and MySQL_V8. The suite covers repository CAS, reader/writer round-trips, restart, and R2DBC mapping.

Read the core manual, then compare the JDBC adapter before selecting a transaction model.

The adapter does not own pools, schema migration, or exactly-once external effects. Checkpoint persistence remains at-least-once.