All Products
Search
Document Center

Microservices Engine:Connect to an agent (script/big data/SQL tasks)

Last Updated:Mar 11, 2026

Microservices Engine (MSE) lets you write and modify scripts and SQL directly in the console, then schedule and run them on remote machines. To execute these tasks, you deploy a lightweight agent (executor) on an Elastic Compute Service (ECS) instance or container, which connects to your MSE-XXLJOB instance and receives task assignments.

This guide walks you through deploying the agent using an installation package, Docker, or Kubernetes.

Architecture diagram

How it works

Three components work together to schedule and run tasks:

ComponentRoleKey identifier
ApplicationA logical group registered in the MSE console. Tasks and executors are organized under applications.AppName, AccessToken
Agent (executor)A process deployed on your machine that polls the admin server for tasks and runs them.Configured with AppName and AccessToken
Admin serverThe MSE-XXLJOB control plane that dispatches tasks to connected agents.Service registration address

When the agent starts, it registers with the admin server using the configured AppName and AccessToken. Once connected, it receives and runs tasks assigned to its application, including Shell scripts, Python, Node.js, Go, SQL, and big data jobs.

Configuration reference

All three deployment methods use the same parameters. The following table maps each parameter across configuration methods.

ParameterYAML key (application.yml)Environment variableDescriptionWhere to find it
Service registration addressxxl.job.admin-addressesSCHEDULERX3_ADMIN_ADDRESSESAdmin server URL that the agent connects toInstance details page in the MSE console
Application AppNamexxl.job.executor.appnameSCHEDULERX3_EXECUTOR_APPNAMEIdentifier for the applicationApplication Management page
Application AccessTokenxxl.job.access-tokenSCHEDULERX3_ACCESS_TOKENAuthentication token for executor registrationApplication Management page
JVM optionsN/A (set via JAVA_OPTS)JAVA_OPTSJVM memory and GC settingsN/A

Create a regular application

Before deploying the agent, create an application in the MSE console to register your executor against.

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

  2. Click the target instance to open the instance details page.

  3. In the left-side navigation pane, choose Application Management, and then click Create Application.

  4. Set Application Type to Regular Application, configure other parameters as needed, and click OK.

After the application is created, note the AppName, AccessToken, and the service registration address from the instance details page. You need these values to configure the agent.

Deploy the agent

Choose one of the following deployment methods based on your environment.

Deploy with an installation package

This method installs the agent directly on a Linux, Mac, or Windows machine.

Prerequisites

  • JDK 17 or later

Step 1: Download and extract the package

wget https://schedulerx3.oss-cn-hangzhou.aliyuncs.com/xxljob/schedulerx3-agent-1.0.0-bin.tar.gz
tar -zxvf schedulerx3-agent-1.0.0-bin.tar.gz
cd schedulerx3-agent-1.0.0-bin

Directory structure after extraction:

schedulerx3-worker-2.4.2-jdk17-bin/
├── bin/              # Startup and management scripts
├── conf/             # Configuration files
│   ├── application.yml      # Application configuration
│   └── logback-spring.xml   # Log configuration
├── lib/              # Dependency JARs
└── logs/             # Log output (created at runtime)

Step 2: Configure the agent

Edit conf/application.yml with your MSE-XXLJOB instance details:

xxl:
  job:
    admin-addresses: <service-registration-address>
    access-token: <application-access-token>
    executor:
      appname: <application-app-name>

Replace the placeholders with values from the MSE console:

PlaceholderDescriptionExample
<service-registration-address>Admin server URL from the instance details pagehttp://192.168.x.x:8080/xxl-job-admin
<application-access-token>AccessToken from the Application Management pagexXxXxXx
<application-app-name>AppName from the Application Management pagemy-executor

Step 3: Start the agent

Linux/Mac

# Start in the background
./bin/start.sh

# Start in the foreground (for debugging)
./bin/start.sh -f

# Stop
./bin/stop.sh

# Restart
./bin/restart.sh

# Check status
./bin/status.sh

# View logs
tail -f logs/worker.log

Windows

REM Start in the background
.\bin\start.cmd

REM Start in the foreground (for debugging)
.\bin\start.cmd -f

REM Stop
.\bin\stop.cmd

REM Restart
.\bin\restart.cmd

REM Check status
.\bin\status.cmd

REM View logs
type logs\worker.log

Step 4: Verify the connection

After starting the agent, confirm that it connected successfully:

  1. Check logs/worker.log for a registration success message.

  2. In the MSE console, go to Application Management and verify that the executor appears under your application.

If the executor does not appear, check the following:

  • The service registration address, AppName, and AccessToken are correct.

  • The machine can reach the admin server URL over the network.

  • Port 9999 is open for inbound connections from the admin server.

(Optional) Configure logging

Log files are stored in the logs/ directory. Task execution logs default to ${user.home}/applogs/xxl-job/jobhandler.

Log fileDescriptionRolling policy
stdout.logStandard output (startup log)Script redirection
stderr.logStandard error (exception stacks)Script redirection
worker.logApplication log (INFO and above)100 MB per file, retained for 30 days
error.logError log (ERROR level)50 MB per file, retained for 60 days
gc.logGarbage collection logJVM parameter settings
heap_dump.hprofHeap dump (generated on OOM)--
archive/Archived logs (auto-compressed to .gz)--

To adjust log levels, edit conf/logback-spring.xml:

<!-- Change the root log level -->
<root level="INFO">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="FILE" />
</root>
<!-- Set a package-specific log level -->
<logger name="com.aliyun.schedulerx" level="DEBUG" />
<logger name="com.xxl.job" level="DEBUG" />

(Optional) Tune JVM parameters

Adjust JVM memory based on your workload.

Linux/Mac

# Set temporarily for a single run
JAVA_OPTS="-Xms2g -Xmx4g" ./bin/start.sh

# Set permanently
vim bin/start.sh  # Edit the JAVA_OPTS variable

Windows

REM Set temporarily for a single run
set JAVA_OPTS=-Xms2g -Xmx4g
.\bin\start.cmd

REM Set permanently
notepad bin\start.cmd  REM Edit the JAVA_OPTS variable

Deploy with Docker

Method 1: Use the public image

The public image includes pre-installed Python, Node.js, and Go runtimes for script tasks:

# Pull the image
docker pull schedulerx-registry.cn-hangzhou.cr.aliyuncs.com/schedulerx3/schedulerx3-agent:1.0.0

# Run the agent
docker run -d \
  --name schedulerx3-agent \
  -p 9999:9999 \
  -e JAVA_OPTS="-Xms1g -Xmx2g" \
  -e SCHEDULERX3_ADMIN_ADDRESSES="<service-registration-address>" \
  -e SCHEDULERX3_EXECUTOR_APPNAME="<application-app-name>" \
  -e SCHEDULERX3_ACCESS_TOKEN="<application-access-token>" \
  -v $(pwd)/logs:/opt/schedulerx3-agent/logs \
  --restart unless-stopped \
  schedulerx-registry.cn-hangzhou.cr.aliyuncs.com/schedulerx3/schedulerx3-agent:1.0.0
Important

Keep the AccessToken secure. Do not hardcode it in scripts shared with others. For production deployments, use a secrets manager or environment variable injection.

After the container starts, verify the connection in the MSE console under Application Management.

Method 2: Build a custom image from the tar package

If your tasks require additional dependencies or a custom base image, build your own Docker image:

# Download the installation package
wget https://schedulerx3.oss-cn-hangzhou.aliyuncs.com/xxljob/schedulerx3-agent-1.0.0-bin.tar.gz

# Build the image
docker build -t schedulerx3-agent:1.0.0 -f Dockerfile .

Sample Dockerfile:

################################################################################
### Customize this Dockerfile to install components your tasks require.
################################################################################

# Use your preferred base image with JDK 17+
FROM hub.docker.xxx.com/library/openjdk:17.0.1-jdk-bullseye

LABEL maintainer="SchedulerX Team"
LABEL description="SchedulerX3 Agent - XXL-Job Executor"
LABEL version="2.4.2"

# Configure Alibaba Cloud mirror sources
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    sed -i 's|security.debian.org/debian-security|mirrors.aliyun.com/debian-security|g' /etc/apt/sources.list

# Install Python 3, Node.js, and Go
RUN apt-get update && \
    apt-get install -y python3 python3-distutils curl wget ca-certificates nodejs npm golang-go && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Install pip
RUN curl https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py && \
    python3 /tmp/get-pip.py && \
    rm -f /tmp/get-pip.py && \
    ln -sf /usr/bin/python3 /usr/bin/python

# Set Go environment variables
ENV GOPATH=/root/go
ENV PATH=$GOPATH/bin:$PATH
ENV GO111MODULE=on

# Extract the agent package
COPY schedulerx3-agent-*-bin.tar.gz /tmp/schedulerx3-agent.tar.gz
RUN mkdir -p /opt/schedulerx3-agent && \
    tar -xzf /tmp/schedulerx3-agent.tar.gz --strip-components=1 -C /opt/schedulerx3-worker && \
    chmod +x /opt/schedulerx3-agent/bin/*.sh && \
    mkdir -p /opt/schedulerx3-agent/logs && \
    rm -f /tmp/schedulerx3-agent.tar.gz

WORKDIR /opt/schedulerx3-agent

EXPOSE 9999

CMD ["bin/start.sh", "-f"]

Deploy on Kubernetes

  1. Create a schedulerx3-agent.yaml deployment manifest:

    Note

    For production deployments, store the AccessToken in a Kubernetes Secret rather than in the deployment manifest directly.

        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: schedulerx3-agent
          labels:
            app: schedulerx3-agent
        spec:
          replicas: 1
          selector:
            matchLabels:
              app: schedulerx3-agent
          template:
            metadata:
              labels:
                app: schedulerx3-agent
            spec:
              containers:
                - name: schedulerx3-agent
                  image: schedulerx-registry.cn-hangzhou.cr.aliyuncs.com/schedulerx3/schedulerx3-agent:1.0.0
                  imagePullPolicy: Always
                  ports:
                    - containerPort: 9999
                  env:
                    - name: "SCHEDULERX3_ADMIN_ADDRESSES"
                      value: "<service-registration-address>"
                    - name: "SCHEDULERX3_EXECUTOR_APPNAME"
                      value: "<application-app-name>"
                    - name: "SCHEDULERX3_ACCESS_TOKEN"
                      value: "<application-access-token>"
                  livenessProbe:
                    tcpSocket:
                      port: 9999
                    timeoutSeconds: 30
                    initialDelaySeconds: 30
  2. Apply the deployment:

        kubectl apply -f schedulerx3-agent.yaml
  3. Verify the pod is running: After the pod reaches Running status, confirm the agent appears in the MSE console under Application Management.

        kubectl get pods -l app=schedulerx3-agent

Create and run a task

After the agent connects, create a task to verify the setup.

  1. On the instance details page, in the left-side navigation pane, choose Task > Task Management.

  2. Click Create Task and configure the following settings. This example uses a Shell script task:

    • Set Associated Application to the regular application you created.

    • Set Task Type to Shell.

    Note

    If the agent runs on a Unix/Linux system, set File Format to Unix.

  3. On the Task Management page, click Run Once in the Actions column to run a test execution.

  4. In the left-side navigation pane, choose Task Instances to view execution records. Click Log to view the detailed output.