GLUE script task

Updated at:

A GLUE script task is an online scripting mode in XXL-JOB. This mode lets you write and publish scripts in various languages directly on the MSE XXL-JOB console to dynamically update scheduled task logic without redeploying the application.

Comparison of GLUE script and BEAN tasks

Dimension

GLUE script task

BEAN task

Execution method

Forks a child process to execute the script. Each execution creates a separate process, resulting in 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. The executor forks a child process for each task run, consuming more resources than a BEAN task.

Low. Shares the JVM resources of the executor application.

Update method

Online updates that take effect immediately. Changes are applied after you edit and save the script in the console, with no deployment required.

Code changes require redeployment. You must modify the Java code, package it, and publish a new version of the executor application.

Developer efficiency

High. Suitable for scenarios that require rapid iteration and validation.

Lower. Follows standard software development and release 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.

Prerequisites

  • Engine version: MSE XXL-JOB v2.2.2 or later.

  • Supported scripting languages: Java, Shell, Python, PHP, Node.js, and PowerShell.

Create a GLUE script task

Procedure

  1. Log on to the MSE XXL-JOB console and select a Region in the top menu bar.

  2. On the Task Scheduling > XXL-JOB page, click the target instance.

  3. In the left-side navigation pane, choose Application Management, click Create Application, set the application type to Standard Application, and then click OK.

  4. Connect an executor. We recommend using the MSE-developed executor, which supports features such as custom variables and custom return values.

  5. In the left-side navigation pane, choose Task Management, and then click Add Task.

  6. On the Add Task page, select an associated application and configure the task settings.

    Note
    • Job Type: Select the job type corresponding to your scripting language.

    • Script Content: The script the task executes.

    • (Optional) Task parameters: The way you configure parameters depends on the job type.

      • BEAN and Groovy tasks: Configure parameters in the Job Parameters field. The value is passed to the @XxlJob handler method as a JSON-formatted string. In your handler method, declare a String param parameter and use a library such as Jackson to deserialize it to the target type. Example:

        @XxlJob("myJobHandler")
        public void myJobHandler(String param) throws Exception {
            Map<String, List<String>> data = objectMapper.readValue(
                param, new TypeReference<Map<String, List<String>>>(){});
        }

        If the handler method does not explicitly receive this parameter, the configured value cannot be retrieved.

      • Shell, Python, PHP, Node.js, and PowerShell tasks: Configure parameters in the Custom Parameters section. Each entry requires a variable name, direction, type (default: VARCHAR), and value.

    • (Optional) One-time task scheduling: To run a task exactly once at a specific time, in the Schedule Type drop-down list, select one_time. The Scheduling Time date-time picker appears. Enter the execution time in yyyy-MM-dd HH:mm:ss format (for example, 2025-06-15 12:00:00). The selected time must be no earlier than 24 hours before the current time.

      Note

      Cron expressions in MSE XXL-JOB support only recurring task scheduling and do not support specifying the year. To schedule a task to run once at a specific future time, use the one_time schedule type instead of a cron expression.

  7. Click Complete.

Manage GLUE script tasks

Update a script

  1. In the Task Management list, find the task that you want to modify.

  2. In the Running Mode column, click Edit Script.

  3. In the Edit Script window, modify the script content and click OK.

  4. In the Latest Version window, enter the version name and click OK.

Compare historical versions

  1. In the Task Management list, find the task that you want to modify.

  2. In the Running Mode column, click Edit Script.

  3. In the Edit Script window, enable Compare Versions.

  4. Select a version to view its content and changes.

FAQ

How do I troubleshoot a "Read timed out" error with a 3-second timeout?

This error is typically caused by network connectivity issues or executor overload. To troubleshoot:

  1. Check whether the executor node that handled the failed task experienced network jitter, high load, or frequent Full GC at the time of the failure.

  2. Verify whether only long-running tasks are affected. Tasks that finish within 3 seconds are not subject to this timeout. If only long-running tasks trigger this error, the likely cause is executor processing latency rather than a configuration issue.