Skip to main content

Customization Platform

Ratchet customization is CDI-first. To override the reference implementation, provide an @ApplicationScoped bean for the SPI you want to replace and mark it as an enabled CDI alternative:

import static jakarta.interceptor.Interceptor.Priority.APPLICATION;

import jakarta.annotation.Priority;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Alternative;

@Alternative
@Priority(APPLICATION)
@ApplicationScoped
public class AppExecutionTuningProvider implements ExecutionTuningProvider {
// ...
}

No string-based implementation class names are loaded by Ratchet. This keeps the customization model portable across Jakarta runtimes and testable with normal CDI tooling.

Extension Points

SPIDefaultUse it to customize
RatchetConfigSourceSource-chain fallback behind RatchetOptionsWhere raw fallback config comes from, such as database-backed config or a platform config service
ExecutionTuningProviderRatchetOptions-backed thread pool and virtual-thread settingsPer-execution-type concurrency and virtual-thread backpressure limits
PollingStrategyProviderAdaptive RI polling strategyPoll cadence, backoff, burst behavior, or an externally coordinated polling policy
JobInvocationResolverASM-based lambda/method-reference analysisHow submitted callbacks become persisted target-method invocations
ResultPersistenceStrategyJSON result metadata with a size capReturn-value serialization, truncation, redaction, or disabling result persistence
JobLoggerFactoryJBoss Logging-backed per-job loggerJob-scoped structured logging and log event publishing
CircuitBreakerConfigProviderRatchetOptions-backed built-in breaker settingsCircuit breaker enablement and per-profile thresholds
ResilienceStrategyBuilt-in circuit breaker wrapperReplace the built-in resilience layer entirely
SchedulerLifecycleHookNo hooks by defaultStartup/shutdown integration with external systems
ClassPolicyEmpty allowlist, fail-fast at startupSecurity boundary for job target classes
ErrorSanitizerCommon PII redactionDomain-specific error redaction
RetryPolicyDefers to job retry settingsException-aware retry decisions
MetricsCollectorNo-opMetrics backend integration
BeanResolverCDI lookupCustom target instance resolution
ExecutorProviderDefault managed executor providerExecutor ownership and scheduling executor selection
NodeIdentityProviderStore-backed node identity and heartbeatCloud or orchestrator-specific node identity
ClusterCoordinatorNo-opCross-node coordination beyond the store-backed wakeup path
StartupCoordinatorStore-backed startup lockStartup leadership and one-time maintenance gates

SerializationStrategy and LambdaAnalyzer remain in the API for compatibility, but the scheduler's primary payload path is now JobInvocationResolver. Return values are handled by ResultPersistenceStrategy.

Configuration Model

Applications must produce an @ApplicationScoped RatchetOptions bean — Ratchet refuses to start otherwise. See Configuration for the canonical patterns.

RatchetConfigSource is an advanced overlay: produce it only when your platform already owns raw configuration and you want a producer that calls RatchetOptionsFactory.fromEnvironment(yourSource) to fold that platform on top of the ambient RATCHET_* / MicroProfile Config chain.

Deeper Customization

Use these hooks when changing scheduler behavior rather than just tuning values:

@Alternative
@Priority(APPLICATION)
@ApplicationScoped
public class TenantAwareExecutionTuning implements ExecutionTuningProvider {
@Override
public boolean useVirtualThreads() {
return true;
}

@Override
public int maxConcurrency(String executionTypeName, int defaultValue) {
return switch (executionTypeName) {
case "BATCH_CHILD" -> 80;
case "DLQ_ALERT" -> 4;
default -> defaultValue;
};
}

@Override
public int virtualThreadLimit(String executionTypeName, int defaultValue) {
return "WORKFLOW_JOIN".equals(executionTypeName) ? 500 : defaultValue;
}
}

For payload customization, implement JobInvocationResolver. The resolver must return a stable class name, method name, JVM method descriptor, static/instance flag, and argument list. This is the contract that is persisted in the job store.

For lifecycle integration, implement SchedulerLifecycleHook. Hook failures are logged and do not prevent Ratchet startup or shutdown; use them for integration and telemetry, not as a hard deployment gate.