In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the function of the distributed scheduling framework xxl-job". In the daily operation, I believe that many people have doubts about the role of the distributed scheduling framework xxl-job. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods, hoping to help you answer the doubts about "what is the role of the distributed scheduling framework xxl-job?" Next, please follow the editor to study!
1. Timed task usage scenarios
Backup data regularly, order timeout is automatically cancelled, according to time period statistics, coupons will expire to send users a reminder, and so on.
2. The basic concept of scheduled tasks.
Executor: responsible for performing tasks.
Scheduler: instructs the executor to perform the task according to the configuration (cron expression) details
Task: your own business implementation, such as a coupon that expires, sends a reminder to the user.
3. Scheduled tasks are used in spring.
@ Slf4j@Component / / make spring manage @ EnableScheduling / / scheduled task annotations public class Timer {@ Autowired IPayRecordService iPayRecordService; @ Scheduled (cron = "0Accord 10 *?") Public void notifyOrder () {log.info ("timer notifyOrder...."); try {iPayRecordService.notifyOrder ();} catch (Exception e) {log.error ("notifyOrder error:", e);}
4. Problems existing in spring scheduled tasks.
Cluster deployment is not supported: for example, if you start three instances, each instance will trigger the executor to perform the task of "sending a reminder to the user when the coupon expires", which leads to the problem of repeated execution. It is usually deployed on a single machine, and there is a risk of dying on a single machine.
Failed retry is not supported: the task ends when an exception occurs, and the task cannot be reexecuted according to the execution status.
Does not support dynamic management: does not support do not restart the task, close and start the task, modify the cron expression and so on.
No alarm: cannot send alarm notification after task failure
Sharding task is not supported
Wait.
5. The implementation idea of distributed timing task framework.
The scheduling center configures cron expressions, routing policies, and bean instances of processing classes, such as demoHandler.
Routing strategy means how to choose an actuator, such as randomly selecting one, training in rotation, etc. The scheduling center notifies the executor of the task through RPC and enters the task queue of the executor with the name of the processing bean (demoHandler). The execution engine of the executor will extract the task from the task queue and obtain the corresponding bean instance for execution according to the name of bean.
The actuator needs to have a heartbeat to the dispatching center, and the actuator that has not received the heartbeat for a long time will be removed by the dispatching center.
6. Why use XXL-JOB?
XXL-JOB is a lightweight distributed task scheduling platform, and its core design goal is rapid development, easy learning, lightweight and easy to expand. Now open source code and access to a number of companies online product lines, out of the box.
At present, a number of companies have connected to xxl-job, including the more well-known Dianping, JD.com, Youxin used cars, Beijing Suntech, 360Finance, Lenovo Group (Lenovo), easy Credit (NetEase) and so on.
7. Why not use quartz?
There are some problems with Quartz:
Problem 1: the way of calling API to operate tasks is not humanized.
Problem 2: the business QuartzJobBean needs to be persisted to the underlying data table, and the system intrusion is quite serious.
Problem 3: the scheduling logic and QuartzJobBean are coupled in the same project, which will lead to a problem. When the number of scheduling tasks increases gradually and the scheduling task logic increases gradually, the performance of the scheduling system will be greatly limited by the business.
Problem 4: the bottom layer of quartz acquires the DB lock by "preemption" and the successful node is responsible for running the task, which will lead to a great disparity in node load; while XXL-JOB implements "cooperative distribution" to run tasks through executors, giving full play to the advantages of the cluster and balancing the load among nodes.
XXL-JOB makes up for the above shortcomings of quartz.
8. The XXL-JOB highly available dispatch center will deploy multiple xxl-job-admin. How to ensure that the distribution tasks of multiple dispatch centers are distributed only once? (version V2.0.1)
The scheduling adopts a central design, and the "scheduling center" is implemented based on cluster Quartz and supports cluster deployment, which ensures that the scheduling center HA; and implements tasks only once in multiple machines in the cluster through database pessimistic locks.
At this point, the study on "what is the role of the distributed scheduling framework xxl-job" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 247
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.