All Products
Search
Document Center

Microservices Engine:Connect a Spring Boot application to SchedulerX

Last Updated:Oct 24, 2025

This topic describes how to connect a Spring Boot application to the Alibaba Cloud SchedulerX service. You will learn how to create an application, configure connection parameters, and set up and verify the client in your Spring Boot project. This process ensures that your application runs smoothly on the SchedulerX platform and enables automated scheduling and precise task management.

Prerequisites

  • Optional. A namespace is created. If your application requires high security, you can create a namespace to isolate its resources and services. For more information, see Create a namespace.

  • A Spring Boot project is created.

Overview

To connect a Spring Boot application to SchedulerX, perform the following steps:

  1. Create a SchedulerX application. Create an application in SchedulerX to obtain connection parameters and to centrally manage and configure tasks.

  2. Connect your Spring Boot application to SchedulerX. In your project's .properties or .yml file, configure the parameters that are required by SchedulerxWorker and create a task processor class.

  3. Verify the result. Confirm that the Spring Boot application is connected and runs as expected.

Step 1: Create an application

1.1 Basic configuration

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

  2. On the Application Management page in the left navigation bar. Select the target Namespace, and click Create Application. Enter the Application Name and Application ID, select the Application Type, configure advanced settings as needed, and click Next.

    image

    Important

    Make sure that resources are created in the selected region and namespace and the resource information is valid.

    Configuration item

    Description

    Default value

    Application Name

    Customize the application name.

    None

    Application ID

    The Application ID is the GroupID for application access. It must be unique within the same namespace. Otherwise, the creation fails. It can be the same as the Application Name.

    None

    Application Type

    • Regular App: Select this option if the application is not deployed in a Kubernetes cluster or does not require Kubernetes jobs.

    • k8s App: Select this option if you want to deploy the application in a Kubernetes cluster and require Kubernetes jobs.

    Regular App

    Edition

    Select an edition based on your requirements.

    Professional Edition

    Simple Log Service

    If you enable this feature, add a Log4j or Logback configuration. Then, you can view the scheduling logs of jobs, including distributed jobs, in the console for troubleshooting.

    Off

    load5

    The value cannot be greater than the number of CPU cores available on the client machine.

    0

    Memory Usage

    If the average memory usage within the previous 5 minutes exceeds the threshold that is specified by this parameter, the worker is considered busy.

    90%

    Disk Usage

    If the disk usage exceeds the threshold that is specified by this parameter, the client machine is considered busy.

    95%

    Trigger Busy Machine

    Specify whether to continue to trigger job execution when the machine is busy.

    On

    Advanced Configuration

    Maximum Number Of Jobs

    Specify the maximum number of jobs that are supported in a group.

    1000

    Automatic Scale-out

    Specify whether to enable automatic scale-out. If you enable this feature, you need to set Global Job Count.

    Off

    Traffic Throttling

    Specify whether to enable traffic throttling. If you enable this feature, you need to set Task Instance Concurrency.

    Off

    Calendar

    You can select Financial Day or Workday from the drop-down list to schedule the application.

    • Financial day: a trading day for financial business.

    • Workday: a day of normal work or operations for a society, organization, or individual.

    0

1.2 Notification configuration

  1. On the Notification Configuration wizard page, enter the relevant information, select a Notification Channel, and set Contacts.

    • The Notification Channel supports Text Message, Email, Webhook, and Phone.

      For more information about Webhook configuration, see Webhook configuration description.

    • Notification Contacts supports two methods: contact groups and contacts.

      • Contact Group

        All contacts in the contact group can receive notifications. For more information about how to create a contact group, see Create a notification contact or notification contact group.

      • Contact

        1. Added contacts can receive notifications. You can add multiple contacts at a time. After you Add Contact, click Go To Create Contact.

        image

        1. In the dialog box that appears, click Create Contact, and enter the contact information.

        image

        Configuration item

        Description

        Notification Channel

        The following notification channels are supported: Text Message, Email, Webhook, and Phone.

        Email

        Enter the email address of the contact.

        Webhook

        • Enter the webhook URL that you want to use. WeCom, Lark, and DingTalk are supported. You can also specify multiple webhook robots at a time. Separate multiple robot links with commas (,).

        • You need to add the keyword "SchedulerX" (case-sensitive) to the DingTalk robot. Otherwise, you cannot receive alert information.

        • For more information about how to obtain a webhook URL, see DingTalk Developer Documentation, WeCom Developer Documentation, and Lark Developer Documentation.

        Mobile Phone Number

        Enter the mobile phone number of the contact.

  2. Verification

    Refresh the page and select the specified region and namespace. Then, view the information about the created application.

Step 2: Connect a Spring Boot application to SchedulerX

  1. Add the dependency to the pom.xml file

    Add the SchedulerxWorker dependency to the pom.xml file of your Spring Boot application. This allows the application to use the features that are provided by SchedulerX.

    Note

    SchedulerX supports connections from Spring Boot 2.x and 3.x applications.

    <dependency>
      <groupId>com.aliyun.schedulerx</groupId>
      <artifactId>schedulerx2-spring-boot-starter</artifactId>
      <version>${schedulerx2.version}</version>
      <!-- If you use Logback, exclude Log4j and Log4j 2. -->
      <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>                   
    Important

    Replace <version>${schedulerx2.version}</version> with the latest client version. For example: <version>1.11.5</version>. For more information, see Client version release notes.

  2. Configure parameters

    In the application.properties configuration file of your Spring Boot application, add the SchedulerxWorker parameters, such as connection and authentication information, that are required to connect to the SchedulerX application.

    spring.schedulerx2.endpoint=${endpoint}
    spring.schedulerx2.namespace=${namespace}
    spring.schedulerx2.groupId=${groupId}
    # The appKey parameter is supported only for agent versions 1.2.1 and later.
    spring.schedulerx2.appKey=${appKey}
    
    # If you do not use an appKey, you can use an Alibaba Cloud AccessKey ID and AccessKey secret, or an STS token.
    #spring.schedulerx2.aliyunAccessKey=${aliyunAccessKey}
    #spring.schedulerx2.aliyunSecretKey=${aliyunSecretKey} 
    #spring.schedulerx2.stsToken=${aliyunStsToken}                   

    Source of the parameter:

    On the Application Management page in the navigation pane on the left of the MSE SchedulerX console, click Access Configuration in the Actions column for the target application. Then, select Spring Boot as the service type.

    image

    Important

    Ensure that the SchedulerX region and the agent region are the same. Otherwise, the agent cannot connect to SchedulerX.

    If your application runs on a non-Alibaba Cloud server or in an on-premises environment, make sure that you have enabled Internet access for the application and created a SchedulerX application in the Internet region. For more information, see Connect to SchedulerX over the Internet from an on-premises environment.

    Note

    If your client application contains multiple service modules or you need to isolate scheduled tasks for permission management, you can create multiple applications in the console to implement fine-grained management of scheduled tasks. For example, for the client application animals, you can create two applications, animals.dog and animals.cat, in the console. You do not need to request separate instances for the two applications. Instead, you only need to specify spring.schedulerx2.groupId=${groupId} in the application.properties configuration file and separate the application names with commas. For example: spring.schedulerx2.groupId=animals.dog,animals.cat.

    Parameter descriptions

    • endpoint: To initialize SchedulerxWorker, you must specify the endpoint of the region where your application is deployed. For more information, see Endpoint List.

    • namespace: The namespace ID, which you can find on the Namespaces page in the console.1

    • `groupId` is the application ID, and `appKey` is the application key. You can obtain these values on the Application Management page in the console.1

    • aliyunAccessKey and aliyunSecretKey: The AccessKey ID and AccessKey secret of your Alibaba Cloud account. You can log on to the User Information Management console and obtain an AccessKey pair from the Security Information Management page.

    • The following table describes other parameters.

      Key

      Description

      Set value

      Initial version

      spring.schedulerx2.enabled

      Specifies whether to enable the starter of SchedulerX 2.0. Default value: true. No configuration is required.

      true

      false

      0.1.7

      spring.schedulerx2.endpoint

      The endpoint of the specified region. For more information, see Endpoint List.

      N/A

      0.1.7

      spring.schedulerx2.namespace

      The UID of the namespace. You can obtain the namespace UID on the Namespaces page of the console.

      None

      0.1.7

      spring.schedulerx2.groupId

      The ID of the application. You can find the application ID on the Application Management page in the console.

      N/A

      0.1.7

      spring.schedulerx2.appKey

      The application key. You can find the application key on the Application Management page in the console.

      N/A

      1.2.1

      spring.schedulerx2.host

      Set the actual IP address if multiple IP addresses exist, such as from a VPN or multiple network interface cards (NICs).

      N/A

      0.1.7

      spring.schedulerx2.port

      The custom port on which the client listens. If you do not set a port, the system randomly selects an available port.

      None

      0.1.7

      spring.schedulerx2.blockAppStart

      Specifies whether to block the application startup if SchedulerX fails to initialize. The default is true.

      true

      false

      1.1.0

      spring.schedulerx2.shareContainerPool

      Specifies whether all task executions on the client share the thread pool. Default value: false.

      true

      false

      1.2.1.2

      spring.schedulerx2.sharePoolSize

      The size of the thread pool if the shared thread pool is enabled. The default value is 64.

      None

      1.2.1.2

      spring.schedulerx2.label

      Set tags on different clients. Task management can then specify these tags for task execution. This is useful for scenarios such as canary releases and stress testing.

      N/A

      1.2.2.2

      spring.schedulerx2.enableCgroupMetrics

      Specifies whether to use cgroup to collect metrics for a client instance. Default value: false. You must manually enable this feature in a Kubernetes container environment.

      true

      false

      1.2.2.2

      spring.schedulerx2.cgroupPathPrefix

      The path of the cgroup in the container.

      The default path is /sys/fs/cgroup/cpu/. If the path already exists, you do not need to set this parameter.

      1.2.2.2

      spring.schedulerx2.enableHeartbeatLog

      Specifies whether to write heartbeat logs to the ${user.home}/logs/schedulerx/heartbeat.log file.

      Default value: true.

      true

      false

      1.2.4

      spring.schedulerx2.mapMasterStatusCheckInterval

      The frequency at which the Map model checks whether all sub-tasks are complete. Unit: milliseconds. To increase the scheduling frequency for second-granularity jobs, configure this parameter.

      3000

      1.2.5.2

      spring.schedulerx2.enableSecondDelayCycleIntervalMs

      Specifies whether to use milliseconds as the unit for the `second_delay` latency. The default value is false. If you set this parameter to true, the console interprets the second-level latency in milliseconds instead of seconds. This increases the scheduling frequency.

      true

      false

      1.2.5.2

      spring.schedulerx2.broadcastMasterExecEnable

      Specifies whether the primary node participates in broadcast task execution. The default value is true.

      true

      false

      1.8.13

      spring.schedulerx2.broadcastDispatchRetryTimes

      The maximum number of retries after a broadcast fails. By default, no retry is performed. The retry interval is fixed at 2 s and cannot be configured.

      3

      1.8.13

      spring.schedulerx2.enableSecondDelayStandaloneDispatch

      Controls whether standalone jobs are dispatched every second. The default is false.

      true

      false

      1.8.13

  3. Create a task processor class

    Create a JobProcessor class in the Spring Boot application to enable job scheduling.

    The following sample code shows how to schedule a simple JobProcessor class that periodically prints a message. In this example, the message is hello schedulerx2.0.

    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;
    
    @Component
    public class MyHelloJob extends JavaProcessor {
    
        @Override
        public ProcessResult process(JobContext context) throws Exception {
            System.out.println("hello schedulerx2.0");
            return new ProcessResult(true);
        }
    }              

Step 3: Verify the result

Log on to the MSE SchedulerX console. In the left navigation bar, click Application Management and view the Total Instances of the target application.

image

Note
  • If Total Instances is 0, the application failed to connect. Check and modify the local application.

  • If Total Instances is not 0 and shows the number of connected instances, the application is successfully connected.

What to do next

After the application is connected to SchedulerX, you can create scheduling tasks in the Distributed Task Scheduling Platform. For more information, see Create a scheduling task.

FAQ

References

For more information about other client connection types, see Quickly connect a client to SchedulerX.