GLUE script tasks
GLUE (Online Script) is an online script task pattern in XXL-JOB. This pattern lets you write and publish scripts in multiple languages directly in the MSE XXL-JOB console. You can use these scripts to dynamically update the business logic of scheduled tasks without redeploying your application.
Comparison between GLUE tasks and BEAN tasks
Dimension | GLUE script task | BEAN task |
Execution method | Executes the script by forking a child process. Each execution creates a separate process, which results in some system overhead. | Executes within a thread. The task runs as a JobHandler in the thread pool of the executor's JVM. Resources are shared, and the overhead is low. |
Resource overhead | High. When a task runs, the executor forks a child process to run the script. This consumes more resources than a BEAN task. | Low. Shares the JVM resources of the executor application. |
Update method | Online updates that take effect immediately. Changes take effect after you edit and save the script in the console. No deployment is required. | Code changes require redeployment. You must modify the Java code, then package and publish a new version of the executor application. |
Developer efficiency | High. Suitable for scenarios that require rapid iteration and validation. | Low. Follows standard software development and publishing processes. |
Recommended scenarios | Scenarios with infrequent task scheduling, such as data cleaning, report generation, and API integration. | Core business logic, high-frequency scheduled tasks, and complex computations. |
Scope
Engine version: MSE XXL-JOB Edition v2.2.2 or later.
Supported scripting languages: Java, Shell, Python, PHP, NodeJs, and PowerShell.
Create a GLUE script task
Procedure
Log on to the MSE XXL-JOB console and select a Region from the top menu bar.
On the Task Scheduling > XXL-JOB Version page, click the target instance.
In the navigation pane on the left, choose Task Management, and then click Create Task.
On the Create Task page, select an associated application and complete the task configuration.
NoteThe associated application must be a common application. If no such application is available, you must first create a common application.
For more information about other configuration items, see Create a scheduled task.
Job Type: Select the GLUE task type that corresponds to your scripting language.
Script Content: The script code that the task executes.
Click Complete.
Manage GLUE script tasks
Update a script
In the Task Management list, find the Job that you want to modify.
In the Running Mode column, click Edit Script.
In the Edit Script window, modify the script content, and click OK.
In the Latest Version window, enter the version name, and click OK.
Compare historical versions
In the Task Management list, find the Job that you want to modify.
In the Running Mode column, click Edit Script.
In the Edit Script window, enable Version Comparison.
Select a version name to view the historical version and its changes.