Erupt Job Scheduled Tasks
erupt-job provides visual scheduled task management, supporting Cron expression configuration, task log viewing, email sending, and more. All tasks are managed through the interface with no application restart required.
Adding the Dependency
<dependency>
<groupId>xyz.erupt</groupId>
<artifactId>erupt-job</artifactId>
<version>${erupt.version}</version>
</dependency>To enable email sending, add the mail configuration to application.yml:
spring:
mail:
username: [email protected]
password: 123456
host: smtp.exmail.qq.com
port: 465
properties:
mail.smtp.ssl.auth: true
mail.smtp.ssl.enable: true
mail.smtp.ssl.required: trueAfter starting the application, the Task Management, Task Logs, and Send Email menus are automatically added.
Settings
erupt:
job:
# Enable job scheduling, default true; when off the menus remain but no job is triggered
enable: true
# Max time the cluster lock is held (ms); must exceed the longest job run, default 30 min; only applies with redis-session on
lock-at-most-for-millis: 1800000
# Min time the lock is held after a job finishes (ms), absorbs clock skew between instances; keep below the shortest cron interval, default 1 s
lock-at-least-for-millis: 1000Features
Task Management
Add scheduled tasks, configure Cron expressions, handler classes, and task parameters. Tasks can be enabled or disabled:

Add a new task:

Task Logs
View execution records including execution time, parameters, return values, and task status:

Log details:

Send Email
Uses the mailbox configured in application.yml as the sender, and supports rich-text content:


Defining a Handler Class
Handler classes must implement the EruptJobHandler interface and be registered as Spring Beans:
@Service
public class DemoJobHandler implements EruptJobHandler {
/**
* Task execution logic
* @param code Task code (matches the task code configured in the interface)
* @param param Task parameters (matches the task parameters configured in the interface)
* @return The return value is recorded in the task log
*/
@Override
public String exec(String code, String param) {
log.info("Executing scheduled task, code={}, param={}", code, param);
// Business logic...
return "Execution successful";
}
// Task name; supported from 1.12.14+, displayed in the interface dropdown
@Override
public String name() {
return "Demo Scheduled Task";
}
// Default Cron expression; supported from 1.12.14+
@Override
public String cron() {
return "0/10 * * * * ?";
}
}Cluster Deduplication v2.1.1+
In a multi-instance deployment, scheduled jobs would by default run once on every instance. With erupt.redis-session = true, erupt-job automatically enables a Redis-backed cluster lock (ShedLock) so each job runs on exactly one node across the cluster, avoiding duplicate execution:
erupt:
redis-session: trueSingle-instance deployments require no configuration and incur no extra overhead.
Configuration in Task Management
| Field | Description |
|---|---|
| Task Code | Unique identifier; corresponds to the code parameter of the handler's exec method |
| Cron Expression | Task schedule rule, e.g. 0 0 2 * * ? means every day at 2:00 AM |
| Handler Class | Select from registered EruptJobHandler implementations |
| Task Parameters | Optional; passed as the param argument to the handler's exec method |