Skip to main content

Installation

Ratchet is distributed as a set of Maven modules. You pick the modules you need, import the BOM for version alignment, and apply the database schema. This page walks through each step.

Maven BOM Setup

The Bill of Materials (BOM) ensures all Ratchet modules use the same version. Import it in your <dependencyManagement> section:

<dependencyManagement>
<dependencies>
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet-bom</artifactId>
<version>0.1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

With the BOM imported, you can declare Ratchet dependencies without specifying versions:

<dependencies>
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet-api</artifactId>
</dependency>
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet</artifactId>
</dependency>
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet-store-postgresql</artifactId>
</dependency>
</dependencies>

Module Overview

Ratchet is split into focused modules so you only pull in what you need. Here's what each module does and when you need it.

Required Modules

ModulePurposeYou need it when...
ratchet-apiPublic API: JobSchedulerService, JobBuilder, annotations (@Recurring, @CircuitBreakerProtected), events, and SPI interfacesAlways. This is the module you code against.
ratchetReference implementation: poller, execution engine, CDI producers, retry logic, circuit breaker, lambda serializationAlways (unless you're writing your own implementation of the API).
ratchet-store-coreShared persistence abstractions: entity classes and the composed JobStore SPIAlways. Pulled in transitively by any store module.

Store Modules (Pick One)

You need exactly one store module matching your database:

ModuleDatabaseNotes
ratchet-store-postgresqlPostgreSQL 14+Uses JSONB columns, partial indexes, and FOR UPDATE SKIP LOCKED for efficient job claiming
ratchet-store-mysqlMySQL 8+Uses JSON columns and SELECT ... FOR UPDATE SKIP LOCKED
ratchet-store-mongodbMongoDB 6+Document-based store with TTL indexes

Optional Modules

ModulePurposeYou need it when...
ratchet-micrometerMicrometer metrics adapter implementing MetricsCollector SPIYou want to export scheduler metrics to Prometheus, Datadog, or any Micrometer-supported backend
ratchet-tck-storeStore SPI conformance contracts (CRUD, claiming, archiving, batches, locks).You're validating a custom JobStore for "Ratchet Store Compatible".
ratchet-tck-apiPublic-API conformance contracts (submit / cancel / retry / idempotency / workflow / delayed scheduling). Container-free, pure-JVM JUnit.You're validating a custom JobSchedulerService for "Ratchet API Compatible".
ratchet-tck-jakartaJakarta-EE conformance contracts (CDI injection, CDI events, JTA enqueue) driven by Arquillian.You're validating a runtime for "Ratchet Jakarta Runtime Compatible".

Choosing Your Modules

Minimal Setup

For most applications, you need three dependencies: the API, the reference implementation, and your store:

<dependencies>
<!-- The API you code against -->
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet-api</artifactId>
</dependency>

<!-- The engine that runs your jobs -->
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet</artifactId>
</dependency>

<!-- Your database store (pick one) -->
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet-store-postgresql</artifactId>
</dependency>
</dependencies>
Why three modules?

Ratchet separates the API from the implementation so that modules in your application that only submit jobs can depend on ratchet-api alone, without pulling in the execution engine. This is useful in multi-module projects where a shared library needs to enqueue jobs but doesn't run the scheduler.

With Metrics

Add ratchet-micrometer to export scheduler metrics (job counts, execution times, retry rates, circuit breaker state) to your monitoring stack:

<dependencies>
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet-api</artifactId>
</dependency>
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet</artifactId>
</dependency>
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet-store-mysql</artifactId>
</dependency>
<!-- Metrics export -->
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet-micrometer</artifactId>
</dependency>
</dependencies>

API-Only (Shared Library)

If you have a shared library that needs to define job signatures but doesn't run the scheduler itself:

<dependencies>
<dependency>
<groupId>run.ratchet</groupId>
<artifactId>ratchet-api</artifactId>
</dependency>
</dependencies>

This gives you access to JobSchedulerService, @Recurring, JobBuilder, and all event types -- enough to write code that submits and observes jobs. The deployment that actually runs the scheduler adds ratchet and a store module.

Transitive Dependencies

Ratchet keeps its dependency footprint small. Here's what each module brings in:

ModuleKey Dependencies
ratchet-apijakarta.enterprise.cdi-api (for @InterceptorBinding on @CircuitBreakerProtected)
ratchetASM 9.7.1 (lambda bytecode analysis), cron-utils 9.2.1 (cron expression parsing), JBoss Logging; Jakarta EE APIs are provided by the runtime
ratchet-store-coreJakarta Persistence / JSON APIs, ASM, JBoss Logging
ratchet-store-mysql / ratchet-store-postgresqlSQL store logic; JDBC drivers are supplied by the application server or your deployment
ratchet-store-mongodbMongoDB sync driver
ratchet-micrometerMicrometer Core 1.14

Jakarta EE APIs are declared with provided scope, since your Jakarta EE 10/11 application server supplies them at runtime.

Database Schema Setup

SQL stores ship DDL as plain SQL files -- no Flyway dependency, no migration framework lock-in. You apply the schema using whatever mechanism your project already uses for DDL management. MongoDB collections and indexes are initialized by ratchet-store-mongodb at startup.

The SQL files are located in each SQL store module's resources:

ratchet-store-postgresql/src/main/resources/ddl/postgresql-schema.sql
ratchet-store-mysql/src/main/resources/ddl/mysql-schema.sql

Applying the Schema

Command line:

# PostgreSQL
psql -d mydb -f ratchet-store-postgresql/src/main/resources/ddl/postgresql-schema.sql

# MySQL
mysql mydb < ratchet-store-mysql/src/main/resources/ddl/mysql-schema.sql

Flyway (if you already use it):

Copy the DDL file into your Flyway migrations directory with an appropriate version number:

src/main/resources/db/migration/V10__ratchet_schema.sql

Liquibase:

Reference the DDL file as a sqlFile changeset in your changelog.

Why plain SQL?

This is a deliberate design decision. Other schedulers (like Quartz) bundle their own migration framework, which creates conflicts when your application already manages schema migrations with Flyway or Liquibase. By shipping raw DDL, Ratchet integrates with whatever migration strategy you've already chosen -- or none at all, if you apply schema changes manually.

Store-Specific UUID Wiring

Ratchet job IDs are UUIDv7 values. PostgreSQL stores them as native uuid. MySQL stores them as BINARY(16) and production persistence units must include the MySQL mapping file:

<mapping-file>META-INF/orm-mysql.xml</mapping-file>

That mapping applies the MySQL store-local UuidByteArrayConverter for non-Hibernate JPA providers. PostgreSQL does not use this mapping file. MongoDB clients must use UuidRepresentation.STANDARD; prefer MongoClientFactory.create(...) when creating the client.

Jakarta EE Server Compatibility

Ratchet targets Jakarta EE 10/11 runtimes with the services used by the reference implementation. The default runtime requirements are:

  • CDI 4.0/4.1 -- for dependency injection, bean discovery, and event observation
  • JPA 3.1/3.2 -- for the store implementations' entity mapping
  • Interceptors 2.1/2.2 -- for @CircuitBreakerProtected support
  • Jakarta Concurrency 3.0/3.1 -- for the default managed executor provider

Servers known to work:

ServerVersionNotes
WildFlyJakarta EE 10 line; CI-managed tests currently use 39.0.1.FinalPrimary managed test target
Open LibertyJakarta EE 10 webProfile-10.0; CI-managed tests currently use 26.0.0.2Requires CDI, Persistence, and managed executor support
PayaraPayara 6 line; CI-managed tests currently use 6.2025.11Jakarta EE 10 runtime
GlassFishGlassFish 8 / Omnifish lineJakarta EE 11 verification profile; currently tracked with a known upstream workaround

Plain Web Profile or standalone CDI environments can opt into run.ratchet.ri.cdi.StandaloneExecutorProvider as an alternative ExecutorProvider. That fallback owns unmanaged executors and is intended for tests, demos, and non-container deployments.

What's Next

With your dependencies in place and the schema applied, you're ready to write your first job:

  • Quick Start -- Minimal working example in under 5 minutes
  • Your First Job -- Complete walkthrough with retries, callbacks, and monitoring