Chronicle for Kotlin and Java
The Chronicle JVM client lets a Kotlin or Java application append events,
build read models from them, and react to them, with annotations on ordinary
data classes and records. Kotlin gets a coroutine API; Java has blocking
wrappers. One artifact, io.cratis:chronicle, serves both.
New here? Start with Get started.
This section covers what is specific to the JVM: installation, connection setup, Spring Boot, annotations, and the API reference. Shared Chronicle concepts and workflows live in the main Chronicle docs and show Kotlin and Java tabs next to the other clients.
Requirements and compatibility
Section titled “Requirements and compatibility”- Client,
io.cratis:chronicle: Java 17 or later, andkotlinx-coroutines1.10.2 or later at runtime. - Spring Boot starter,
io.cratis:chronicle-spring-boot-starter: Spring Boot 4 (built against 4.1.1); the per-request features need the servlet stack. - In-process testing,
io.cratis:chronicle-testing: any test runner and no kernel.
All three are released together with the same version number. The client ships with Kotlin 2.4 and brings the Kotlin standard library with it, so a Java application needs no Kotlin setup.
The client checks compatibility with the kernel every time it connects, and refuses to send anything to a kernel that cannot serve it. There is no published version matrix. Client 6.5.0 has been exercised against kernel 19.6.1. Kernel 19.4.8 rejects it at connect time. Treat other pairings as unverified until that check and your own tests pass. See Connection lifecycle.
Kotlin and Java setup
Section titled “Kotlin and Java setup”Add the client to your Gradle build. The examples in this section use
7.11.0, including the Fundamentals types such as
io.cratis.fundamentals.geospatial that arrived in 7.x; the
latest release is
on Maven Central:
dependencies { implementation("io.cratis:chronicle:7.11.0")}Maven uses the same coordinates, io.cratis:chronicle:7.11.0. The same JVM
client supports both Kotlin and Java. Shared pages include separate Kotlin
and Java tabs when both examples exist.
Spring Boot applications add the starter instead. It brings the client with it and wires everything up:
dependencies { implementation("io.cratis:chronicle-spring-boot-starter:7.11.0")}For local development, use either the standalone image or the Docker Compose example below, not both.
Standalone development image
Section titled “Standalone development image”You need a running Chronicle kernel. For a first try, the development image runs on its own:
docker run --rm -p 127.0.0.1:35000:35000 cratis/chronicle:latest-developmentDevelopment Docker Compose
Section titled “Development Docker Compose”Alternatively, use Docker Compose to run the development kernel and database in
separate containers. Chronicle serves gRPC, the API, and health checks on port
35000 over TLS with a self-signed development certificate. The ports below
are bound to loopback so the development kernel and database are not
reachable from other machines:
services: chronicle: image: cratis/chronicle:latest-development-slim depends_on: - mongodb - mongodb-init environment: - ASPNETCORE_ENVIRONMENT=Development - Cratis__Chronicle__Storage__Type=MongoDB - Cratis__Chronicle__Storage__ConnectionDetails=mongodb://mongodb:27017/?directConnection=true ports: - "127.0.0.1:35000:35000"
mongodb: image: mongo:8.2 command: ["mongod", "--replSet", "rs0", "--bind_ip_all"] ports: - "127.0.0.1:27017:27017"
# Chronicle's MongoDB storage needs a replica set — initiate it once. mongodb-init: image: mongo:8.2 depends_on: - mongodb restart: "no" command: - /bin/bash - -lc - | until mongosh --host mongodb --quiet \ --eval "db.adminCommand('ping')" >/dev/null 2>&1; do sleep 1 done mongosh --host mongodb --quiet --eval " try { rs.status(); } catch (e) { rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'mongodb:27017' }] }); }"Chronicle is ready once curl -sk https://localhost:35000/health reports
Healthy. The Samples/Kotlin/Console and Samples/Java/Console folders
in the repository contain a similar file along with PostgreSQL, SQL Server,
and SQLite profiles. Their ports are not bound to loopback, so Docker
publishes them on every network interface and the kernel and databases are
reachable from other machines. Add 127.0.0.1: to their port mappings, as
above, before running them on a shared network.
Client-specific pages
Section titled “Client-specific pages”Choose a next step for your application:
- Get Started: install the JVM client, connect, append an event, and read the read model it produces, in Kotlin and Java
- Artifact Registration: how artifacts are discovered and registered, and how to narrow or turn that off
- Spring Boot: the starter, multi-tenancy, and per-request identity, causation and units of work
- Testing: specify appends and reducers in-process, without a kernel
- Connection lifecycle: what happens on connect, reconnect and failure, and how to troubleshoot it
- Reference: annotations, configuration, and service API details
- All JVM guides