Enterprise Distributed Application Service (EDAS) integrates SchedulerX into the console as a component to schedule jobs. This topic describes how to use SchedulerX to schedule jobs in Spring Cloud applications, deploy the applications to EDAS, and implement job scheduling in Simple Job Single-instance Edition mode.

Why is SchedulerX used?

SchedulerX is a distributed job scheduling service that is developed by Alibaba. It provides a second-level scheduling service that is accurate, highly reliable, and highly available based on CRON expressions. It also provides models for running distributed jobs, such as grid jobs.

Schedule jobs in your on-premises environment

  1. Create a Maven project named scx-example.
  2. In the following sample code, Spring Boot 2.1.4.RELEASEand Spring Cloud Finchley.SR1 are added as dependencies to the pom.xml file.
    • If you must use Spring Boot 1.x, we recommend that you use Spring Boot 1.5.x and Spring Cloud Edgware. The corresponding version of Spring Cloud Alibaba is 1.5.1.RELEASE.
    • Spring Boot 1.x has reached end of life. Therefore, we recommend that you use a later version of Spring Boot to develop your applications.
  3. Create a startup class that is named ScxApplication for scx-example.
     import org.springframework.boot.SpringApplication;
     import org.springframework.boot.autoconfigure.SpringBootApplication;
     public class ScxApplication {
         public static void main(String[] args) {
             SpringApplication.run(ScxApplication.class, args);
  4. Create a simple class that is named TestService and use Spring to inject the class to the Inversion of Control (IoC) test job.
     import org.springframework.stereotype.Service;
     public class TestService {
         public void test() {
             System.out.println("---------IOC Success--------");
  5. Create a simple class that is named SimpleTask as the test job class and inject TestService to the class.
     import com.alibaba.edas.schedulerx.ProcessResult;
     import com.alibaba.edas.schedulerx.ScxSimpleJobContext;
     import com.alibaba.edas.schedulerx.ScxSimpleJobProcessor;
     import org.springframework.beans.factory.annotation.Autowired;
     public class SimpleTask implements ScxSimpleJobProcessor {
         private TestService testService;
         public ProcessResult process(ScxSimpleJobContext context) {
             System.out.println("-----------Hello world---------------");
             ProcessResult processResult = new ProcessResult(true);
             return processResult;
  6. Run the main function in ScxApplication to start the service.

Verify the result

View the standard output in the IntelliJ IDEA console. You can find that the following test information is periodically displayed:

-----------Hello world---------------
---------IOC Success--------            

Deploy the application to EDAS

Spring Cloud AliCloud SchedulerX is developed to respond to the needs of migrating applications from their original development environments to EDAS. You can deploy applications to EDAS without the need to modify the code or configurations. For more information about deployment methods and steps, see Overview and Overview.

After the application is deployed, you can schedule jobs in the EDAS console.

What to do next

After your application is deployed to EDAS, you can use the SchedulerX component to implement more job scheduling features.