Distributed scheduling platform XXL-JOB Quick and issue summary

1.XXL-JOB Profile

XXL-JOB is a lightweight distributed task scheduling framework. It's core design goal is to develop quickly and learn simple, lightweight, and easy to expand. Now, it's already open source, and many companies use it in production environments, real "out-of-the-box".

XXL-JOB is a lightweight distributed task scheduling platform, its core design goal is to develop rapid, simple to learn, lightweight, easy to expand. Open source and now online companies access to the product line, out of the box.

- Quote from GIT project XXL-JOB Introduction

QEOvzq.png

The other describes the XXL-JOB can refer to the official website of Chinese document describes , it is rich in features, added support for distributed and dynamic access control and other tasks as well.

2. The project to build a XXL-JOB

① Download Source
https://github.com/xuxueli/xxl-job/
② execute SQL
xxl-job-2.1.1\xxl-job-2.1.1\doc\db\tables_xxl_job.sql
③ modify the configuration
### xxl-job, datasource
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?Unicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=root_pwd
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
### xxl-job, access token 秘钥填了 下面的子项目要和这个一致
xxl.job.accessToken=

Note that the configuration of subprojects to address and admin access in the same home address:

### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
④ start the project

We need to start the project in the choice of admin, then start xxl-job-executor-samples the following, where we start, here is a relatively simple way to start springboot by example, which is also the author recommended start-up mode.

After starting the access control center access to the address: http: // localhost: 8080 / xxl-job-admin (the executor will be used to address, as a callback address)

The default login Account "admin / 123456", the login operation interface is shown below

QV3nw6.png

Configuring about job can refer to Demo sample, and then we add time with BEAN model name is the name of @Service:

/**
 * 任务Handler示例(Bean模式)
 *
 * 开发步骤:
 * 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”;
 * 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例;
 * 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
 * 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
 *
 * @author xuxueli 2015-12-19 19:43:36
 */
@JobHandler(value="demoJobHandler")
@Component
public class DemoJobHandler extends IJobHandler {

    @Override
    public ReturnT<String> execute(String param) throws Exception {
        XxlJobLogger.log("XXL-JOB, Hello World.");
        System.out.println("XXL-JOB, Hello World.");
        for (int i = 0; i < 5; i++) {
            XxlJobLogger.log("beat at:" + i);
            TimeUnit.SECONDS.sleep(2);
        }
        return SUCCESS;
    }
}

3. Summary of issues

  • Connection is not on the database?
    Needs to be configured Datasource relevant connections in the admin, there is need to fill in the correct password.
  • Execution log has been in execution, callback failure?
    Configuration subproject when we must address and admin access agreement for the callback.
  • Can not find coding interface?
    GLUE mode only when selected in the new, write code to use interface, supports version rollback.
  • Actuator Management does not take effect?
    AppName and configuration to the inside of the same, and manually add the address to be consistent netty external port number (not the start of autumn tomcat port number), the default is 9999.

Guess you like

Origin www.cnblogs.com/charlypage/p/11963522.html