Open-Job

一个企业级分布式任务调度系统,定时调度基于时间轮算法实现,调度中心与执行器通信支持 Grpc,同时支持 Netty,执行器支持集群部署,任务分片执行,任务支持监控报警能力。

🍪 快速开始

1 搭建任务管理系统

  1. 创建数据库表

sql 文件在 doc/db/open_job.sql

  1. 启动 Dashboard 服务
@EnableSecurity
@EnableScheduling
@EnableOpenRpcClient
@SpringBootApplication
public class JobDashboardApplication {

    public static void main(String[] args) {
        SpringApplication.run(JobDashboardApplication.class, args);
    }
}
  1. 启动执行器
@EnableOpenRpcServer
@SpringBootApplication
public class JobClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(JobClientApplication.class, args);
    }
}
  1. 下载前端项目
git clone https://github.com/lijunping365/Open-Job-Admin.git
  1. 安装依赖
npm install
  1. 启动前端项目
npm start

2 创建 JobHandler

示例 1

@Slf4j
@JobHandler(name = "job-one")
@Component
public class OpenJobHandlerOne implements OpenJobHandler {

    @Override
    public void handler(JobParam jobParam) {
        log.info("JobHandlerOne 处理任务");
    }
}

示例 2

@Slf4j
@Component
public class OpenJobHandlerMethodOne{

    @JobHandler(name = "job-method-one1")
    public void handlerOne1(JobParam jobParam) {
        log.info("JobHandlerOne 处理任务, 任务参数 {}", jobParam.getParams());
    }

    @JobHandler(name = "job-method-one2")
    public void handlerOne2(JobParam jobParam) {
        log.info("JobHandlerOne 处理任务, 任务参数 {}", jobParam.getParams());
    }
}