Skip to content
Projets

À propos

基于Spring Boot + Quartz 的分布式任务调度系统

Développement web et applicatif

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

schedule-job License Build Status unstable

项目基于 jdk1.8 采用 Spring Boot 框架

  • 集成了分布式任务调度框架 Quartz ,任务存储于数据库。
  • 使用SpringMVC作为路由控制, 集成 Swagger2 提供实时 RESTful API文档。
  • 数据持久层集成 Mybatis 框架。
  • 使用自定义注解 @TargetDataSource 实现了多数据源动态切换,支持数据库读写分离。
  • HTTP JOB 接口调用使用 OkHttp3 替代了 HttpClient 。
  • Thrift JOB 接口调用实现了 Thrift client 池化管理。
  • 集成了 Spring data redis,提供缓存服务。
项目目标
  • 该项目计划实现通过RESTful接口,动态管理基于Http(已完成)和Thrift调用的Quartz任务(任务的 添加、查询、禁用、启用、触发)。 比如添加一个基于HTTP接口调用的定时任务,只需要向接口传递JSON数据。
常见问题
  • 如何启动项目或启动失败?

需要在脚本里添加SPRING_CONFIG_NAME=app,datasource,quartz,redis。可参照项目里bin/service.sh

  • Spring Boot如何集成Mybatis?

Mybatis官方已经提供了spring-boot-starter-mybatis

  • Spring Boot如何集成Redis?

参照confing/redis 相关类

  • Spring Boot如何集成Quartz?

参照config/quartz下相关类

  • Spring Boot如何实现动态选择数据源(读写分离)?

参照anno/TargetDataSource,aspect/TargetDataSourceAspect注解类实现

提供接口
  • 查询任务列表接口
curl -X GET -H "Cache-Control: no-cache" "http://localhost:54321/jobs"
  • 添加任务接口
curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
  "jobDO": {
    "description": "测试心跳检测",
    "group": "TEST_HTTP_JOB",
    "name": "test_heart_beat",
    "extInfo": {
      "type": "http_job",
      "method": "get",
      "url": "http://localhost:54321/heart_beat",
      "jsonParams": ""
    }
  },
  "triggerDOs": [
    {
      "cronExpression": "0/30 * * * * ?",
      "description": "心跳检测每30秒调用一次",
      "group": "TEST_HTTP_TRIGGER",
      "name": "test_heart_beat_trigger"
    }
  ]
}' "http://localhost:54321/jobs"
  • 查询任务接口
curl -X GET -H "Cache-Control: no-cache" "http://localhost:54321/jobs/{jobKey}/"
  • 移除任务接口
curl -X DELETE -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
    "TEST_HTTP_JOB" : ["sync_test_job"]
}' "http://localhost:54321/jobs"
  • 触发任务接口
curl -X POST -H "Content-Type: application/json" 
             -H "Cache-Control: no-cache" -d '' "http://localhost:54321/jobs/{groupName}/{taskName}"

Explorer des projets similaires

Chargement…