Elastic Job Lite Spring Boot Starter
前言
Elastic-Job-Lite 是一个分布式调度解决方案,定位为轻量级无中心化解决方案,使用jar包的形式提供分布式任务的协调服务。
本项目将 Elastic-Job-Lite 封装为基于注解形式的使用,即 @ElasticJobLite(),去掉了 默认的 xml 配置文件。
使用方式
下载源码 Elastic Job Lite Spring Boot Starter,用maven编译成功。创建你的Spring Boot项目,并在 pom.xml 中添加依赖:
<dependency>
<groupId>com.shu.elasticjob.spring.boot</groupId>
<artifactId>elastic-job-lite-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
创建作业任务服务类:
- Simple类型的任务 (监听器可选)
@ElasticJobLite(cron = "0/5 * * * * ?", jobName = "MySimpleJob", shardingTotalCount = 3,
shardingItemParameters = "0=B,1=S,2=G", listenerName = "mySimpleJobListener")
public class MySimpleJob implements SimpleJob {
@Autowired
private MyJobService myJobService