Class SchedulingInterceptor

java.lang.Object
io.fluxzero.sdk.scheduling.SchedulingInterceptor
All Implemented Interfaces:
DispatchInterceptor, HandlerDecorator, HandlerInterceptor

public class SchedulingInterceptor extends Object implements DispatchInterceptor, HandlerInterceptor
Intercepts scheduled messages to handle periodic scheduling logic.

This interceptor enables powerful scheduling features such as:

  • Initial scheduling of @Periodic types: When a handler method or its parameter type is annotated with Periodic, this interceptor will automatically initialize the schedule at startup if autoStart=true.
  • Rescheduling on success or failure: Upon successful or failed invocation of a scheduled handler, this interceptor can reschedule the next invocation based on the result or according to cron/delay rules.
  • Metadata injection: Adds the scheduleId metadata to outgoing scheduled messages to support correlation and rescheduling.
  • Dynamic behavior based on handler return value: Supports dynamic rescheduling based on return types like TemporalAmount, TemporalAccessor, Schedule, or even a replacement payload object.

Additionally, if the scheduled handler throws a CancelPeriodic exception, the schedule is permanently cancelled without logging an error.

This interceptor is registered automatically with Fluxzero.

See Also: