This article is a mirror article of machine translation, please click here to jump to the original article.

View: 22839|Reply: 0

[Source] 【Practical Practice】XXL-JOB Distributed Task Scheduling Platform Use and Development Tutorial

[Copy link]
Posted on 9/7/2021 4:35:50 PM | | | |
XXL-JOB is a distributed task scheduling platform with the core design goals of rapid development, simple learning, lightweight, and easy to scale. It is now open source and connected to the online product lines of many companies, and is ready to use out of the box.
Review:

.net/c# Quartz.NET Remote Task Scheduling [with source code]
https://www.itsvse.com/thread-4729-1-1.html

Quartz CronTrigger is the most complete configuration description
https://www.itsvse.com/thread-4573-1-1.html

Quartz.net Simple configuration tutorial
https://www.itsvse.com/thread-4297-1-1.html

asp.net MVC utilizes Quartz.Net plugins to execute scheduled tasks
https://www.itsvse.com/thread-3308-1-1.html

GitHub address:The hyperlink login is visible.

Official document address:The hyperlink login is visible.

First, download the source code, address:The hyperlink login is visible.(Download via domestic gitee)

Create database and table structures

Script file address:/xxl-job/doc/db/tables_xxl_job.sql, import the script into the MySQL database, and the script will automatically determine whether there is a xxl_job database and automatically create a xxl_job database, create the corresponding table structure and insert the initial data. As shown below:


Open the project

Use Eclipse to import the Maven project and compile it with Maven.

The source code structure is as follows:

xxl-job-admin: Dispatch center
xxl-job-core: Common dependencies
xxl-job-executor-samples: Executor Sample example (select the appropriate version of the executor, you can use it directly, or you can refer to it and convert an existing project into an executor)
:xxl-job-executor-sample-springboot:Springboot version, through Springboot management executor, this method is recommended;
:xxl-job-executor-sample-frameless: unframed version;




Run the xxl-job-admin scheduling center


xxl-job-admin to configure the mysql database connection

Open the /xxl-job/xxl-job-admin/src/main/resources/application.properties configuration file and configure it as follows:


Open the XxlJobAdminApplication.java file and start the project.

Access the web management interface at the following address:http://127.0.0.1:8080/xxl-job-admin, as shown in the figure below:



Default login account "admin/123456




Run the actuator project

Find the xxl-job-executor-sample-springboot project and modify the application.properties configuration file as follows:

Official detailed explanation of actuator configuration:

### Dispatch Center Deployment and Address [Optional]: If there are multiple addresses in the dispatch center cluster, they are separated by commas. The executor will use this address to register the "Executor Heartbeat" and "Call Back the Task Result". If it is empty, auto-registration is turned off.
xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
### Actuator communication TOKEN [optional]: enabled when not empty;
xxl.job.accessToken=
### Actuator AppName [Optional]: The grouping basis for actuator heartbeat registration; If it is empty, turn off auto-enrollment
xxl.job.executor.appname=xxl-job-executor-sample
### Executor Registration [Optional]: Use this configuration as the registration address first, and use the embedded service "IP:PORT" as the registration address when it is empty. This provides more flexible support for container type executors, dynamic IP and dynamic mapping port issues.
xxl.job.executor.address=
### Executor IP [Optional]: The default is empty to automatically obtain the IP, and the specified IP can be set manually when the NIC is multi-card, which will not be bound to the host and is only useful for communication. Address information for "Executer Registration" and "Dispatch Center Request and Trigger Task";
xxl.job.executor.ip=
### Actuator port number [optional]: If it is less than or equal to 0, it will be automatically obtained; The default port is 9999, so when deploying multiple actuators on a single machine, pay attention to configuring different actuator ports.
xxl.job.executor.port=9999
### Executor Run Log File Storage Disk Path [Optional]: You need to have read and write permissions on this path; If it is empty, the default path is used;
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
### Number of days to save the trigger log file [Optional]: Expired logs are automatically cleaned, and the limit value is greater than or equal to 3. otherwise, such as -1, turn off the automatic cleaning function;
xxl.job.executor.logretentiondays=30


Open the Dispatch Center management platform, click the Scheduler Management menu, add a scheduler, and fill in the appname: xxl-job-executor-itsvse

Open the XxlJobExecutorApplication.java file and try to start the executor as shown below:



The xxl-job-executor-sample-springboot project will open two ports, port 8081 is for external interface services, and port 9999 is for xxl-job-admin calls (used to communicate with the scheduling platform).




Create a new scheduling task

Executor Select the actuator we just created, Cron will execute once in 10 seconds (*/10 * * * * ?), select "BEAN" in the running mode, fill in the JobHandler: demoJobHandler, and fill in the other options at will, just save it.



Start the task on the far right side of the list, and then click Query Log, as shown in the following figure:




Through the logs of the dispatch center platform and the executor, you can see that the task is successfully executed, and the task is executed once every 10 seconds.

(End)





Previous:Nginx implements the function of adding watermark to images
Next:Linux Overlay file system in Docker
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com