当前位置:网站首页>Quick start to elastic job, three minutes to experience distributed scheduled tasks
Quick start to elastic job, three minutes to experience distributed scheduled tasks
2022-06-10 20:48:00 【Wangfugui who lost his hair】
First we need to understand ElasticJob What is it? ?
ElasticJob It is a distributed scheduling solution for Internet Ecology and massive tasks , By two independent subprojects
ElasticJob-LiteandElasticJob-Cloudform .
It's through flexible scheduling 、 Resource control 、 And the function of job management , Build a distributed scheduling solution for Internet scenarios , And through open architecture design , To provide diversified operation Ecology .
Its products use a unified job API, Developers only need to develop once , You can deploy it as you like .
Look at the difference between them ?

What we are going to talk about this time is lite Version of
The environment we need to prepare :
jdk + zookeeper + maven
Quick start
You can also go directly to my code warehouse to pull it down and run it directly :
https://gitee.com/WangFuGui-Ma/elastic-job-quickstart
First step , Create a maven Project and import jar package
<dependencies>
<dependency>
<groupId>com.dangdang</groupId>
<artifactId>elastic-job-lite-core</artifactId>
<version>2.1.5</version>
</dependency>
</dependencies>

The second step , Create a myjob Class inheritance simplejob class

public class MyJob implements SimpleJob {
public void execute(ShardingContext shardingContext) {
System.out.println(" Scheduled tasks started "+ new Date());
}
}
The third step , Create a JobDemo Start class

public class JobDemo {
public static void main(String[] args) {
new JobScheduler(createRegistryCenter(), createJobConfiguration()).init();
}
private static LiteJobConfiguration createJobConfiguration() {
// Create job configuration
JobCoreConfiguration demoSimpleJob = JobCoreConfiguration.newBuilder("demoSimpleJob", "0/3 * * * * ?", 1).build();
SimpleJobConfiguration simpleJobConfiguration = new SimpleJobConfiguration(demoSimpleJob, MyJob.class.getCanonicalName());
return LiteJobConfiguration.newBuilder(simpleJobConfiguration).build();
}
private static CoordinatorRegistryCenter createRegistryCenter() {
ZookeeperConfiguration zkConfig = new ZookeeperConfiguration("localhost:2181", "elasticJob");
zkConfig.setSessionTimeoutMilliseconds(100);
CoordinatorRegistryCenter elasticJob = new ZookeeperRegistryCenter(zkConfig);
elasticJob.init();
return elasticJob;
}
}
Step four , Start the local zookeeper
If you don't know how to start and install, you can refer to my article :
https://blog.csdn.net/csdnerM/article/details/121848173
Step five , start-up jobdemo
The console will start printing !! Congratulations on completing Elastic-Job A quick start to !!

边栏推荐
- Mixin -- mixed
- P5723 [deep base 4. example 13] prime number pocket
- Elastic-Job的快速入门,三分钟带你体验分布式定时任务
- synergy: server refused client with our name
- [observation] shengteng Zhixing: scene driven, innovation first, press the "acceleration key" for Intelligent Transportation
- 连接mysql报错 errorCode 1129, state HY000, Host ‘xxx‘ is blocked because of many connection errors
- 使用环绕通知对目标方法进行增强—摘抄笔记
- Microsoft Word tutorial "5", how to change the margins and create a newsletter column in word?
- Why do some web page style attributes need a colon ":" and some do not?
- 揭秘:春晚微信红包,是如何抗住 100 亿次请求的?
猜你喜欢

终于有人说清楚了Cookie、Session、Token的区别。详解,面试题。

The most common habits from more than 200 English papers written by gradua

观点丨Play and Earn 会让加密游戏误入歧途

中国工科研究生200多篇英文论文中最常见的习惯(The Most Common Habits from more than 200 English Papers written by Gradua)

pdf. Js----- JS parse PDF file to realize preview, and obtain the contents in PDF file (in array form)

2 pcs share a set of keyboard and mouse

魔塔类游戏实现源码及关卡生成

synergy: server refused client with our name

揭秘:春晚微信红包,是如何抗住 100 亿次请求的?

Four methods to obtain the position index of the first n values of the maximum and minimum values in the list
随机推荐
【Educational Codeforces Round 120 (Rated for Div. 2)】C. Set or Decrease
synergy: server refused client with our name
Build a BPMN modeling Web Service
堆叠条形图鼠标移入tooltip中提示过滤为0元素,实现自定义气泡
【观察】昇腾智行:场景驱动,创新先行,为智慧交通按下“加速键”
Elastic-Job的快速入门,三分钟带你体验分布式定时任务
RuntimeError: Attempting to deserialize object on CUDA device 1 but torch. cuda. device_ count() is 1.
pytorch深度学习——卷积操作以及代码示例
Networkx usage and nx Draw() related parameters
玩艺术也得学数学?
latex tips 绝对值的竖线 \left|\right|
Mobile power supply scheme for outdoor solar camping lamp
8.4v dual lithium battery professional charging IC (fs4062a)
H5 van popup full screen pop-up window, simulates the page fallback effect, supports the return button in the upper left corner, and is suitable for physical return, side sliding and bottom return key
The old programmer said: stop translating the world, developers should return to programming
It took 2 years, 442 authors and 132 institutions! Google released the new benchmark big bench for language model evaluation. 204 tasks comprehensively evaluated the language model ability, with paper
手写代码 bind
【电脑使用】如何设置没有自启项的软件开机启动
The most common habits from more than 200 English papers written by gradua
六级考试-商务英语-考前最后一背