All Products
Search
Document Center

Microservices Engine:Perform canary job scheduling by using label-based routing

Last Updated:Jul 31, 2025

You can use label-based routing to perform canary job scheduling. This method ensures that jobs with a specified label are scheduled to executors with the same label. This topic describes the architecture of label-based routing, best practices for canary job scheduling, and the steps to configure label-based routing.

Architecture of label-based routing

XXL-JOB supports a label-based routing policy. When an executor sends a heartbeat to the server, it includes its label information. You can configure label-based routing for each job by specifying a label. This ensures that each job is scheduled to an executor with the specified label.

Best practices for canary job scheduling

How to perform canary job scheduling

For example, if you want to perform a canary release for data where the user ID starts with 2xx, you can copy a job to create two jobs: jobA-base and jobA-gray. Configure the job parameters for each job. Set the job parameter for jobA-base to userId=-2xx and for jobA-gray to userId=2xx. When jobA-gray is executed, it processes only the data for user IDs that start with 2xx. When jobA-base is executed, it processes the data for user IDs that do not start with 2xx.

How to perform an end-to-end canary release

You can use label-based routing to perform a single-hop canary release. This means you can schedule canary jobs to machines with the label gray. If a job also needs to invoke downstream services, such as microservices or messages, and you want to invoke their canary nodes, you can use MSE Microservices Governance to add all services to a canary lane. This automatically performs an end-to-end canary release.

Steps to configure label-based routing

Step 1: Configure labels for user-side nodes

Enhance using an SDK plug-in (code modification required)

  1. Add the following dependency to the pom.xml file and place it before the xxl-job-core dependency. For more information about the version number, see Version guide.

    <dependency>
      <groupId>com.aliyun.schedulerx</groupId>
      <artifactId>schedulerx3-plugin-xxljob</artifactId>
      <version>${Latest version number}</version>
    </dependency>
  2. When the application starts, add the Java Virtual Machine (JVM) parameter -Dxxl.job.executor.label to set a label. For example, you can run the following sample command to start the application and configure a label.

    java -Dxxl.job.admin.addresses=http://xxljob-xxxx -Dxxl.job.executor.appname=app1 -Dxxl.job.accessToken=xxx -Dxxl.job.executor.label=gray app.jar

Enhance using the agent of MSE Microservices Governance (no code modification required)

  1. Connect your application to the MSE Microservices Governance agent based on your application's deployment method. For more information, see Connect applications.

    Important

    The agent version must be 4.4.0 or later.

  2. Based on your application's deployment method, create and deploy a canary application cluster and an end-to-end canary release lane group. For more information, see End-to-end canary release.

Step 2: Verify the connection

In the navigation pane on the left, click Application Management. On the page that appears, check the Number Of Executors. The connection is successful if the labels of the connected machines are displayed.

Step 3: Configure label-based routing

In the navigation pane on the left, click Job Management. On the page that appears, find the target job and choose More > Specify Machine in the Operation column. Set Specify Type to Label. This ensures that the job runs only on executors with the specified label.