Skip to content

API Reference Overview

Ratchet's public API is organized into two packages: run.ratchet.api for the user-facing API, and run.ratchet.spi for extension points. This page provides a complete index and explains how the pieces fit together.

Package Structure

run.ratchet.api: User-Facing API

Classes and interfaces you use directly when scheduling jobs, building workflows, and observing events.

Class / InterfaceKindPurpose
JobSchedulerServiceInterfacePrimary entry point for scheduling, canceling, pausing, and retrying jobs
JobQueryServiceInterfaceRead-only dashboards/admin API for job lists, detail views, history, and queue health
ClusterQueryServiceInterfaceRead-only sibling of JobQueryService for observing the scheduler node roster
JobBuilderInterfaceFluent builder for configuring individual jobs before submission
RecurringJobBuilderInterfaceBuilder for configuring recurring (cron-based) jobs
BatchBuilderInterfaceBuilder for in-memory batch processing of collections
StreamingBatchBuilderInterfaceBuilder for memory-efficient streaming batch processing
JobContextFinal classThread-local access to job ID, job-scoped logger binding, and parameters during execution
SignalDecisionRecordStructured approval/rejection payload for signal-waiting jobs
JobResult<T>ClassCaptures execution outcome: success/failure, return value, timing, metadata
JobHandleInterfaceLightweight receipt returned after job submission, provides the job ID
JobOptionsRecordImmutable configuration for priority, retries, backoff, and timeout
JobFilterRecordImmutable query criteria for list/search operations
JobPage<T>RecordPage metadata and cursor returned by query operations
JobSummary / JobDetailRecordsLightweight and full read-only job projections
NodeStatusRecordPoint-in-time view of a scheduler node's heartbeat state, liveness, and identity
WorkflowConditionRecordDefines conditions for workflow branching (success, failure, custom, batch)
WorkflowBranchRecordPairs a condition with a task and optional description
BatchContextRecordProgress snapshot for batch jobs (total, completed, failed items)
StreamingBatchContextRecordProgress snapshot during the streaming phase of batch construction
JobPriorityEnumPriority levels: LOWEST, LOW, NORMAL, HIGH, CRITICAL
BackoffPolicyEnumRetry delay strategies: NONE, FIXED, EXPONENTIAL
JobTypeEnumJob categories: SINGLE, RECURRING, BATCH, CHAIN, WORKFLOW, SYSTEM
CircuitBreakerProfileEnumPre-configured circuit breaker profiles: DEFAULT, FAST, CRITICAL, EXTERNAL_API, CLAIM_PATH

run.ratchet.api: Annotations

AnnotationTargetPurpose
@RecurringMethodDeclares a method as a cron-scheduled recurring job
@CircuitBreakerProtectedType, MethodWraps invocations through the ResilienceStrategy circuit breaker
@DoNotRetryTypeMarks exception classes that should never be retried
@IncubatingAnyMarks experimental APIs that may change without deprecation

run.ratchet.api: Functional Interfaces

InterfaceSignaturePurpose
SerializableCheckedRunnablevoid run() throws ExceptionPrimary job task definition
SerializableConsumer<T>void accept(T t)Success callbacks, progress hooks
SerializableBiConsumer<T,U>void accept(T t, U u)Failure callbacks (context + error)
SerializableFunction<T,R>R apply(T t)Value-based workflow conditions
SerializablePredicate<T>boolean test(T t)Custom workflow conditions
SerializableCheckedConsumer<T>void accept(T t) throws ExceptionStreaming batch item processing

run.ratchet.api.event: Event Types

EventFires When
JobStartedEventJob begins execution
JobCompletedEventJob completes successfully
JobFailedEventJob reaches terminal FAILED state
JobRetryingEventJob is being retried
JobExecutionTimedOutEventRunning job exceeds its execution timeout
JobCancelledEventJob cancellation confirmed
JobPausedEventJob paused
JobResumedEventJob resumed
JobDlqEventJob moved to dead letter queue
JobSignalWaitingEventJob created in WAITING state for a named signal
JobSignaledEventSignal delivered to a waiting job
JobSignalTimedOutEventWaiting job exceeded its signal timeout
BatchCompletingEventBatch is finishing
BatchCompletedEventBatch fully complete
ChainStartedEventWorkflow chain begins
ChainCompletedEventWorkflow chain succeeds
ChainFailedEventWorkflow chain fails
WorkflowBranchTriggeredEventA workflow condition matches

run.ratchet.spi: Extension Points

InterfacePurpose
RetryPolicyCustom retry/backoff logic
ResilienceStrategyCircuit breaker / bulkhead wrapping
ClassPolicyDeserialization class allowlist
ErrorSanitizerScrub sensitive data from error messages
JobInvocationResolverCustom callback-to-job invocation resolution
ResultPersistenceStrategyCustom job return-value persistence
ExecutorProviderSupply custom thread pools or virtual threads
BeanResolverCustom bean instantiation (default: CDI)
MetricsCollectorEmit custom metrics (Micrometer, StatsD, etc.)
JobLoggerCustom job logging backend
ClusterCoordinatorDistributed wakeup notifications
StartupCoordinatorStore-backed startup leases for destructive initialization tasks
NodeIdentityProviderIdentify nodes in a cluster
RatchetOptionsRequired @ApplicationScoped CDI-produced runtime options; applications must produce one or the scheduler refuses to start

How to Read This Reference

Entry Point

Start with JobSchedulerService. It is the write-side interface you inject for scheduling and lifecycle operations. Every scheduling operation begins here:

java
@Inject
JobSchedulerService scheduler;

For dashboards, admin tools, and support workflows, inject JobQueryService separately. Keeping the query API separate lets applications grant read-only access without exposing mutation methods.

Building Jobs

JobSchedulerService.enqueue() returns a JobBuilder, which provides the fluent API for configuring retries, priorities, timeouts, workflows, and callbacks before calling submit().

Inside a Running Job

When Ratchet executes your job, JobContext is available on the current thread. Use it to access parameters, the job ID, and the current job-scoped logger binding.

Handling Results

JobResult<T> captures everything about a completed execution and is used in workflow conditions to drive branching logic.

API vs SPI

  • API (run.ratchet.api): Classes you use directly. Stable across minor versions.
  • SPI (run.ratchet.spi): Extension points you implement to customize behavior. Interfaces marked @Incubating may change between minor versions.

To provide a custom SPI implementation, create a CDI bean annotated with @Alternative @Priority(APPLICATION).

Maven Coordinates

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

The ratchet-api module has no runtime dependencies beyond Jakarta EE API types (jakarta.enterprise.cdi-api and jakarta.interceptor-api, both provided by the runtime). It defines the complete public API and SPI surface.

See Also