If your SchedulerX application is deployed in a public network region, you can connect to it from any machine or container that has public network access. This includes non-Alibaba Cloud machines and local development environments. This topic describes how to connect to SchedulerX from your local machine for testing and development.
Prerequisites
-
Note
When creating an application, select a Public Network region.
Procedure
-
Add the SchedulerxWorker dependency to the pom.xml file of your application.
The initialization of SchedulerxWorker varies depending on the application type.
-
For standard Java or Spring applications
<dependency> <groupId>com.aliyun.schedulerx</groupId> <artifactId>schedulerx2-worker</artifactId> <version>${schedulerx2.version}</version> <!--If you use logback, exclude log4j and log4j2. --> <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> -
For Spring Boot applications
-
-
Initialize SchedulerxWorker.
The initialization of SchedulerxWorker varies depending on the application type.
-
For standard Java applications
You can initialize SchedulerxWorker in the main function.
When you initialize SchedulerxWorker, you need the Endpoint (acm.aliyun.com) that corresponds to the Public Network region where your application is deployed.
-
Log on to the Distributed Task Scheduling Platform console.
-
In the top menu bar of the console, switch the region to Public Network.
-
In the navigation pane on the left, click Namespaces. On the Namespaces page, find the Namespace ID.
-
In the left navigation pane, click Application Management. On the Application Management page, you can view the Application ID (groupId) and Application Key (appKey), or click Connection Configuration in the Actions column to obtain the connection configuration.

public void initSchedulerxWorker() throws Exception { SchedulerxWorker schedulerxWorker = new SchedulerxWorker(); schedulerxWorker.setEndpoint("xxxx"); schedulerxWorker.setNamespace("xxxx"); schedulerxWorker.setGroupId("xxxx"); // For versions 1.2.1 and later, you must set the application key. schedulerxWorker.setAppKey("xxxx"); schedulerxWorker.init(); }Note-
If an application includes multiple services or you want to categorize scheduled jobs, you can create multiple groups. For example, for an application named
animals, you can create two groups:animals.dogsandanimals.cats. You do not need to run separate instances for each group. Instead, you can specify a comma-separated list in thegroupIdparameter in your client configuration, such asgroupId=animals.dogs,animals.cats. -
When you initialize the SchedulerxWorker client, you can set other parameters as needed. For more information, see SchedulerxWorker parameters.
-
-
For Spring applications
You can inject the SchedulerxWorker bean in the XML configuration file.
-
Log on to the Distributed Task Scheduling Platform console.
-
In the top menu bar of the console, switch the region to Public Network.
-
In the navigation pane on the left, click Namespaces. On the Namespaces page, find the Namespace ID.
-
In the left navigation pane, click Application Management. On the Application Management page, you can view the Application ID (groupId) and Application Key (appKey), or click Connection Configuration in the Actions column to obtain the connection configuration.

<bean id="schedulerxWorker" class="com.alibaba.schedulerx.worker.SchedulerxWorker"> <property name="endpoint"> <value>${endpoint}</value> </property> <property name="namespace"> <value>${namespace}</value> </property> <property name="groupId"> <value>${groupId}</value> </property> <!-- Set the appKey parameter for versions 1.2.1 and later. --> <property name="appKey"> <value>${appKey}</value> </property> </bean> -
-
For Spring Boot applications
Add the following configurations to the application.properties file:
-
Log on to the Distributed Task Scheduling Platform console.
-
In the top menu bar of the console, switch the region to Public Network.
-
In the navigation pane on the left, click Namespaces. On the Namespaces page, find the Namespace ID.
-
In the left navigation pane, click Application Management. On the Application Management page, you can view the Application ID (groupId) and Application Key (appKey), or click Connection Configuration in the Actions column to obtain the connection configuration.

spring.schedulerx2.endpoint=${endpoint} spring.schedulerx2.namespace=${namespace} spring.schedulerx2.groupId=${groupId} # For versions 1.2.1 and later, set the appKey. spring.schedulerx2.appKey=${appKey}NoteIf an application includes multiple services or you want to categorize scheduled tasks, you can create multiple groups. For example, if the application animals has two new groups, animals.dogs and animals.cats, you do not need to request separate instances to connect to them. In the application client, specify both groups in the groupId parameter. For example: groupId=animals.dogs,animals.cats.
-
-
-
In your application, create a
JobProcessorclass to implement task scheduling.The following sample code shows how to implement a simple JobProcessor class that periodically prints "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); } } -
Run the local application.
Result check
Log on to the Microservices Engine (MSE) console. In the left-side navigation pane, choose Task Scheduling > SchedulerX Version. On the SchedulerX Version page, click Applications in the left-side pane. Then, find the application that you want to manage and click View instances in the Operation column.

-
If the Total number of instances column displays 0, the application fails to connect to SchedulerX. Check and modify the on-premises application.
-
If the Total number of instances column displays an integer other than 0, the application is connected to SchedulerX.