Integrating XXL-JOB with SpringBoot for Distributed Task Scheduling

This article provides a step‑by‑step guide on integrating the lightweight distributed task scheduler XXL‑JOB into a SpringBoot application, covering prerequisite installations, Maven dependency configuration, property settings, JobHandler implementation, and registration to enable scalable and reliable job execution.

Java Captain
Java Captain
Java Captain
Integrating XXL-JOB with SpringBoot for Distributed Task Scheduling

Overview: XXL‑JOB is a lightweight distributed task scheduling platform offering simple, fast, and stable scheduling services. Integrating XXL‑JOB with SpringBoot allows a SpringBoot application to become a distributed system, improving scalability and reliability.

Preparation: Install SpringBoot and set up the development environment, then download and install XXL‑JOB from its official website following the documentation.

Integration steps:

Introduce dependency: Add the XXL‑JOB Maven dependency to the SpringBoot project's pom.xml.

<dependency>
    <groupId>com.xuxueli</groupId>
    <artifactId>xxl-job-core</artifactId>
    <version>latest version</version>
</dependency>

Configure XXL‑JOB: Add configuration properties such as admin address, executor name, IP, port, and log path to application.properties or application.yml.

xxl.job.admin.address=XXL-JOB admin address
xxl.job.executor.appname=executor name
xxl.job.executor.ip=executor IP
xxl.job.executor.port=executor port
xxl.job.executor.logpath=executor log path

Create a JobHandler: Implement the com.xuxueli.xxl.job.handler.JobHandler interface in a Java class and override the execute method with the task logic.

public class MyJobHandler implements JobHandler {
    @Override
    public ReturnT execute(String param) {
        // specific task logic
        return ReturnT.SUCCESS;
    }
}

Register the JobHandler: Define a Spring configuration class that registers the JobHandler bean with the XXL‑JOB platform.

@Configuration
public class XxlJobConfig {
    @Autowired
    private JobHandlerRegistry jobHandlerRegistry;

    @Bean(initMethod = "init")
    public MyJobHandler myJobHandler() {
        return new MyJobHandler();
    }
}
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

javaDistributed Schedulingbackend-developmentSpringBootXXL-JOB
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.