-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from JiazhenBao/main
运行时定时任务依赖库开源
- Loading branch information
Showing
15 changed files
with
921 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 依赖库名称 | ||
当前平台的定时任务能力基于quartz框架。在可视化界面中,可以为某个逻辑设置定时任务的表达式。当制品启动时,根据表达式生成相应的定时任务代码。每个任务对应的逻辑会生成一个handler/job类,该类中包含一个execute方法用于执行任务内容(即逻辑内容)。然而,由于它是基于代码的,仅允许用户在编译前管理定时任务。因此无法在运行时满足客户的需求,即无法动态增加或删除任务。 | ||
|
||
## 逻辑详情 | ||
|
||
### 逻辑一 初始化注册任务(持久化)registerInit | ||
本接口需要在初始化时执行。它用于注册3个定时任务持久化逻辑,逻辑须在IDE实现操作数据库。并且执行logicFunctionList获取当前数据库中所有定时任务,加载到内存中,触发定时任务的启动。IDE中相关操作见使用说明。 | ||
|
||
### 逻辑二 注册逻辑addLogic | ||
|
||
本接口用于把IDE中需要供用户配置定时任务的逻辑,注册到逻辑池中。注册到逻辑池的逻辑,才可以被应用使用者配置任务执行规则。本接口需要在初始化时将所有逻辑注册成功。 | ||
|
||
### 逻辑三 查询所有逻辑(右模糊匹配)listLogic | ||
本接口用于查询逻辑池中所有逻辑。 | ||
|
||
### 逻辑四 立即执行逻辑runLogic | ||
本接口用于执行逻辑池中某个逻辑,可传入入参。 | ||
|
||
### 逻辑五 创建定时任务createTask | ||
通过本接口将逻辑和cron、入参字符串传入,即可创建定时任务。若接口1传入了持久化逻辑,定时任务会持久化到数据库。 | ||
|
||
### 逻辑六 查询已已执行的任务列表(右模糊匹配)listTask | ||
查询内存中已经启动的任务。 | ||
|
||
### 逻辑七 删除定时任务deleteTask | ||
通过taskId删除定时任务。 | ||
|
||
### 逻辑八 暂停任务pauseTask | ||
通过taskId暂停定时任务。 | ||
|
||
### 逻辑九 启动任务startTask | ||
通过taskId启动定时任务。 | ||
|
||
## 使用步骤说明 | ||
见操作文档 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.2.9.RELEASE</version><!--与当前制品应用默认版本统一--> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<groupId>com.netease</groupId> | ||
<artifactId>runtime_tasks</artifactId> | ||
<version>0.2.1</version> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<nasl.ide.version>3.3</nasl.ide.version> | ||
</properties> | ||
<dependencies> | ||
<!--本案例是本地系统引入nasl-metadata-collector-0.8.0.jar的方式。 | ||
若把nasl-metadata-collector-0.8.0.jar安装到自己的maven仓库, | ||
注意修改artifactId和groupId的情况下,不要使用<scope>system</scope>,会在发布时造成依赖中断。 | ||
不修改artifactId和groupId的情况下,nasl-metadata-maven-plugin会做特殊处理--> | ||
<dependency> | ||
<artifactId>nasl-metadata-collector</artifactId> | ||
<groupId>com.netease.lowcode</groupId> | ||
<version>0.8.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>fastjson</artifactId> | ||
<version>1.2.83</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<!-- <scope>provided</scope>--> | ||
</dependency> | ||
<!--制品应用使用Springboot框架,父应用引用了的包,为了防止版本冲突,scope可设置为provided--> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.netease.lowcode</groupId> | ||
<artifactId>nasl-metadata-maven-plugin</artifactId> | ||
<version>1.3.0</version> | ||
<configuration> | ||
<jarWithDependencies>false</jarWithDependencies> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>archive</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
8 changes: 8 additions & 0 deletions
8
runtime_tasks_ext/src/main/java/com/netease/lib/tasks/LibraryAutoScan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.netease.lib.tasks; | ||
|
||
/** | ||
* 依赖库自动扫描类 | ||
* @author system | ||
*/ | ||
public class LibraryAutoScan { | ||
} |
12 changes: 12 additions & 0 deletions
12
.../src/main/java/com/netease/lib/tasks/RuntimeTasksBasicSpringEnvironmentConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.netease.lib.tasks; | ||
|
||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* 加入spring环境配置(在spring.factories中指定) | ||
*/ | ||
@Configuration | ||
@ComponentScan(basePackageClasses = LibraryAutoScan.class) | ||
public class RuntimeTasksBasicSpringEnvironmentConfiguration { | ||
} |
Oops, something went wrong.