Common Listener
public class JobMain {
public static void main(String[] args) {
new ScheduleJobBootstrap(createRegistryCenter(), createJobConfiguration()).schedule();
}
private static CoordinatorRegistryCenter createRegistryCenter() {
CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration("zk_host:2181", "elastic-job-demo"));
regCenter.init();
return regCenter;
}
private static JobConfiguration createJobConfiguration() {
JobConfiguration jobConfiguration = JobConfiguration.newBuilder("test", 2)
.jobListenerTypes("simpleListener", "distributeListener").build();
}
}
Distributed Listener
public class JobMain {
public static void main(String[] args) {
new ScheduleJobBootstrap(createRegistryCenter(), createJobConfiguration()).schedule();
}
private static CoordinatorRegistryCenter createRegistryCenter() {
CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration("zk_host:2181", "elastic-job-demo"));
regCenter.init();
return regCenter;
}
private static JobConfiguration createJobConfiguration() {
JobConfiguration jobConfiguration = JobConfiguration.newBuilder("test", 2)
.jobListenerTypes("simpleListener", "distributeListener").build();
}
}
当前内容版权归 ElasticJob 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ElasticJob .