Elastic-Job
<dependency>
<groupId>com.dangdang</groupId>
<artifactId>elastic-job-lite-core</artifactId>
<version>2.1.5</version>
</dependency>
代码语言:javascript复制public class MessagePushJob implements SimpleJob {
@Override
public void execute(ShardingContext shardingContext) {
System.out.println(shardingContext);
}
}
代码语言:javascript复制public class Startup {
public static void main(String[] args) {
new JobScheduler(createRegistryCenter(), createJobConfiguration()).init();
}
private static CoordinatorRegistryCenter createRegistryCenter() {
CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration("localhost:2181", "elastic-job"));
regCenter.init();
return regCenter;
}
private static LiteJobConfiguration createJobConfiguration() {
// 定义作业核心配置
JobCoreConfiguration simpleCoreConfig = JobCoreConfiguration.newBuilder("messagePushJob", "5 * * * * ?", 3).build();
// 定义SIMPLE类型配置
SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(simpleCoreConfig, MessagePushJob.class.getCanonicalName());
// 定义Lite作业根配置
LiteJobConfiguration simpleJobRootConfig = LiteJobConfiguration.newBuilder(simpleJobConfig).build();
return simpleJobRootConfig;
}
}
elastic-job-lite-console
(控制台)
地址:https://github.com/elasticjob/elastic-job-lite/tree/dev/elastic-job-lite-console
代码语言:javascript复制启动类:com.dangdang.ddframe.job.lite.console.ConsoleBootstrap
登录账号密码:
代码语言:javascript复制root/root 、 guest/guest
其他:
zookeeper
v : 3.5.5
JDK
:
v:1.8