All Products
Search
Document Center

SchedulerX:Connect a Spring Boot application to SchedulerX

Last Updated:Mar 11, 2026

SchedulerX is a distributed job scheduling service in Microservices Engine (MSE). It uses a server-agent architecture: the SchedulerX server handles scheduling and coordination, while an agent embedded in your Spring Boot application executes jobs. After connecting your application, you can define, schedule, and monitor jobs from the SchedulerX console.

Prerequisites

Before you begin, make sure you have:

  • A Spring Boot 2.x or 3.x project

  • (Optional) A namespace for resource isolation -- see the "Create a namespace" section of Namespace management

Step 1: Create a SchedulerX application

Configure basic settings

  1. Log in to the MSE SchedulerX console and select a region in the top navigation bar.

  2. In the left-side navigation pane, click Application Management. Select a Namespace and click Create Application.

  3. Enter the following settings and click Next.

    Important

    Create resources in the correct region and namespace. Make sure the resource information is valid.

    SettingDescriptionDefault
    Application NameA descriptive name for the application.None
    Application IDThe GroupID for agent access. Must be unique within the namespace. Can match the Application Name.None
    Application TypeRegular App -- not deployed in Kubernetes or does not require Kubernetes jobs. k8s App -- deployed in Kubernetes and requires Kubernetes jobs.Regular App
    EditionSelect an edition based on your needs.Professional Edition
    Simple Log ServiceEnable to view scheduling logs in the console. Requires a Log4j or Logback configuration.Off
    load5Maximum 5-minute load average. Cannot exceed the number of CPU cores on the client machine.0
    Memory UsageIf the average memory usage in the past 5 minutes exceeds this threshold, the worker is marked busy.90%
    Disk UsageIf disk usage exceeds this threshold, the client machine is marked busy.95%
    Trigger Busy MachineContinue triggering jobs when the machine is busy.On
    SettingDescriptionDefault
    Maximum Number Of JobsMaximum jobs supported in a group.1000
    Automatic Scale-outEnable to auto-scale. Requires Global Job Count.Off
    Traffic ThrottlingEnable to throttle traffic. Requires Task Instance Concurrency.Off
    CalendarSchedule using Financial Day (trading day) or Workday (business day).0

    image

Configure notifications

  1. On the Notification Configuration page, select a Notification Channel and set Contacts. Add contacts individually or use a contact group. To create a contact group, see Create a notification contact or notification contact group.

    SettingDescription
    Notification ChannelText Message, Email, Webhook, or Phone.
    EmailEmail address of the contact.
    WebhookWebhook URL for WeCom, Lark, or DingTalk. Separate multiple URLs with commas (,). For DingTalk, add the keyword "SchedulerX" (case-sensitive) to the robot configuration. For webhook setup details, see Webhook configuration description. For information about how to obtain a webhook URL, see DingTalk Developer Documentation, WeCom Developer Documentation, and Lark Developer Documentation.
    Mobile Phone NumberPhone number of the contact.

    image

  2. Refresh the page and confirm that your application appears under the selected region and namespace.

Step 2: Add the SchedulerX dependency

Add the schedulerx2-spring-boot-starter dependency to the pom.xml file of your Spring Boot project:

<dependency>
  <groupId>com.aliyun.schedulerx</groupId>
  <artifactId>schedulerx2-spring-boot-starter</artifactId>
  <version>1.11.5</version>  <!-- Replace with the latest version -->
</dependency>
Important

Replace the version with the latest agent version. For version history, see Agent release notes.

If your project uses Logback, exclude the bundled Log4j dependencies:

<dependency>
  <groupId>com.aliyun.schedulerx</groupId>
  <artifactId>schedulerx2-spring-boot-starter</artifactId>
  <version>1.11.5</version>
  <exclusions>
    <exclusion>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
    </exclusion>
    <exclusion>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Step 3: Configure connection parameters

Add the following properties to application.properties:

# Required: SchedulerX connection settings
spring.schedulerx2.endpoint=${endpoint}
spring.schedulerx2.namespace=${namespace}
spring.schedulerx2.groupId=${groupId}
# The appKey parameter is supported only in versions 1.2.1 and later.
spring.schedulerx2.appKey=${appKey}

# If you do not use an appKey, you can use an Alibaba Cloud AccessKey and SecretKey, or an STS token.
#spring.schedulerx2.aliyunAccessKey=${aliyunAccessKey}
#spring.schedulerx2.aliyunSecretKey=${aliyunSecretKey}
#spring.schedulerx2.stsToken=${aliyunStsToken}

Parameter sources:

Log in to the SchedulerX console. In the left-side navigation pane, click Applications. Find the application that you want to manage and click AccessConfig in the Operation column. In the AccessConfig panel, select Spring Boot from the dropdown.

image

Parameter description:

  • endpoint: The endpoint of SchedulerxWorker. The value must match the endpoint of the region in which your application is deployed. For more information, see Endpoints.

  • namespace: The ID of the namespace to which the application belongs. You can view the namespace ID on the Namespaces page of the SchedulerX console. 1

  • groupId and appKey: The ID and key of the application. You can view the values on the Applications page of the SchedulerX console. 1

  • aliyunAccessKey and aliyunSecretKey: The AccessKey ID and AccessKey secret of your Alibaba Cloud account. You can view the AccessKey pair on the Security Management page of the User Management console.

Important

SchedulerX and the agent must be in the same region. A region mismatch causes connection failure. If the application runs outside Alibaba Cloud (on-premises or another cloud provider), enable Internet access and create a SchedulerX application in the Internet region. See Connect to SchedulerX over the Internet from an on-premises environment.

If the application uses YAML, add these settings to application.yml instead:

spring:
  schedulerx2:
    endpoint: ${endpoint}
    namespace: ${namespace}
    groupId: ${groupId}
    appKey: ${appKey}
Note

To manage multiple applications from a single client, separate the application IDs with commas: spring.schedulerx2.groupId=animals.dog,animals.cat. Each application is isolated for permission management and does not require a separate worker.

Optional parameters

The following parameters support advanced use cases:

ParameterDescriptionDefaultSince
spring.schedulerx2.enabledEnable or disable the SchedulerX starter.true0.1.7
spring.schedulerx2.hostSpecify the IP address when the machine has multiple NICs or uses a VPN.Auto-detected0.1.7
spring.schedulerx2.portPort for the agent to listen on.Random available port0.1.7
spring.schedulerx2.blockAppStartBlock application startup if SchedulerX fails to initialize.true1.1.0
spring.schedulerx2.shareContainerPoolAllow all jobs on the agent to share one thread pool.false1.2.1.2
spring.schedulerx2.sharePoolSizeThread pool size when sharing is enabled.641.2.1.2
spring.schedulerx2.labelLabels for targeting specific workers during canary release or stress testing.None1.2.2.2
spring.schedulerx2.enableCgroupMetricsUse cgroup to collect agent metrics. Enable manually in Kubernetes environments.false1.2.2.2
spring.schedulerx2.cgroupPathPrefixcgroup path in the container./sys/fs/cgroup/cpu/1.2.2.2
spring.schedulerx2.enableHeartbeatLogLog heartbeat data to ${user.home}/logs/schedulerx/heartbeat.log.true1.2.4
spring.schedulerx2.mapMasterStatusCheckIntervalInterval (ms) to check task completion in the Map model. Lower values increase scheduling frequency for second-granularity jobs.30001.2.5.2
spring.schedulerx2.enableSecondDelayCycleIntervalMsInterpret second-granularity job intervals in milliseconds instead of seconds.false1.2.5.2
spring.schedulerx2.broadcastMasterExecEnableRequire the primary node to run broadcast jobs.true1.8.13
spring.schedulerx2.broadcastDispatchRetryTimesMax retries after broadcast dispatch fails. Retry interval is fixed at 2 seconds.31.8.13
spring.schedulerx2.enableSecondDelayStandaloneDispatchEnable dispatching of second-granularity standalone jobs.false1.8.13

Step 4: Create a job processor

Create a class that extends JavaProcessor to define job logic. The following example prints a message on each run:

package com.aliyun.schedulerx.test.job;

import com.alibaba.schedulerx.worker.domain.JobContext;
import com.alibaba.schedulerx.worker.processor.JavaProcessor;
import com.alibaba.schedulerx.worker.processor.ProcessResult;
import org.springframework.stereotype.Component;

@Component
public class MyHelloJob extends JavaProcessor {

    @Override
    public ProcessResult process(JobContext context) throws Exception {
        System.out.println("hello schedulerx2.0");
        return new ProcessResult(true);  // Return true to indicate success
    }
}
  • @Component registers the class as a Spring bean so SchedulerX can discover it.

  • Extend JavaProcessor and override process to define the job logic.

  • Return new ProcessResult(true) for success or new ProcessResult(false) for failure.

Step 5: Verify the connection

  1. Start your Spring Boot application.

  2. Log in to the MSE SchedulerX console. In the left-side navigation pane, click Applications.

  3. Find your application and click View instances in the Operation column.

    View instances

  4. Check the Total number of instances column:

    • 0: The connection failed. Check your configuration parameters (region, endpoint, namespace, and GroupID) and verify network connectivity.

    • Greater than 0: The connection succeeded.

What to do next

After the connection is verified, create a job in the SchedulerX console to trigger your job processor. See the "Create a job" section of Job management.

Troubleshooting

SymptomPossible causeSolution
Agent fails to connect (0 instances)Region mismatch between SchedulerX and the agentConfirm both use the same region. Check the endpoint value against Endpoints.
Agent fails to connect (0 instances)Application runs outside Alibaba Cloud without an Internet endpointEnable Internet access and create a SchedulerX application in the Internet region. See Connect over the Internet.
Agent fails to connect (0 instances)Incorrect GroupID or AppKeyOpen Applications > AccessConfig in the console and confirm the values.
Application startup blockedSchedulerX failed to initialize with blockAppStart=true (default)Set spring.schedulerx2.blockAppStart=false to let the application start without SchedulerX, or fix the connection issue first.

See also