What scheduler.x helps
A pluggable lightweight scheduler
based on plain Vert.x core without any external libs for scheduling on time-based: cron and interval or on event-based.
Scheduler.x
follows a modularization design and an event-driven architecture.
Overview
Trigger
Trigger
is a component defines the schedule upon which a given Job
will be executed.
In scheduler.x
, there are some out-of-the-box triggers:
-
cron-trigger
based on Quartz -Unix
cron expression andtimezone
available onJVM
-
interval-trigger
with the following parameters:time interval
,initial delay time
andrepeating
to specify the number of scheduling repetitions. -
event-trigger
a trigger that is scheduled to run on receiving a specific event from aVert.x event-bus
distributed messaging system.
Job
Job
is a place that does your business that you wish to have executed by the scheduler.
Scheduler.x
supports 2 kind of Job:
-
Async job
: a job that does an asynchronous computation and returns an asynchronous result in a non-blocking mode in Vert.xFuture
as an event-loop pattern or JavaFuture
as a thread-based pattern. -
Sync job
: a job that does a simple calculation or complex calculation that takes some significant time in a blocking mode of the current thread.
You can easily extend these interfaces to explore your task in the business model.
Monitor
Scheduler.x
is an event-driven system that decouple the job execution and job reporting.
Without requiring explicit notifications from the Job
itself, the client application(your program) can register a scheduling monitor.
Then, Scheduler.x
can uniformly notify the client of any events occurring within the scheduler.
These events may include the execution result after the trigger is fired and the job is executed, a trigger misfiring for some reason and so on.
Data JSON serializable
The component API in scheduler.x
is designed to be friendly with Vert.x JSON, is also compatible with Jackson.
This makes it easy to serialize all objects into a JSON-formatted string with minimal effort. The resulting string can be transmitted over a network or stored in a file or database, allowing you to store the work data configuration in your desired storage.
Once you restart your program, scheduler.x
will deserialize the JSON data into appropriate objects, which will enable your scheduling work to continue seamlessly.
This allows scheduler.x
to function in both stateful and stateless modes.
Modularization, fluent API and type-safe programming
scheduler.x
is designed based on
-
modularity mechanism is by breaking down the functionality into smaller independent parts that are extensible and interchangeable.
-
a fluent API concept, where multiple methods calls can be chained together
-
type-safe programming, which enforces rules to ensure that operations are performed on compatible types.
I strongly believe that implementing this approach significantly reduces the likelihood of errors, enhances code clarity, maximizes extensibility, and simplifies maintenance for the client application.