Task scheduling and ERP are inseparable — Chapter 18
Log the birth of “open source software”
[Light up the star] —- looking forward to an encouragement
Open source address of blogger:
Yards cloud: gitee.com/redragon/re…
GitHub:github.com/redragon198…
What is task scheduling?
Task scheduling sounds like a fancy word, but it’s not hard to understand. We know that an application performs tasks in real-time and synchronous mode by default, and the so-called task scheduling is to make tasks non-real-time or asynchronous. Another word can be used to describe a scheduled task or a timed task.
What problem does it solve
To analyze the problem solved by task scheduling, we must first look at the characteristics of the task and how it needs to be executed. First of all, this kind of task is generally completed manually by the system according to certain preset logic. Secondly, such tasks need not be completed in real time or at a specific time. After the task is started, it only needs to be executed silently in the background. After the execution is completed, the user can be notified conditionally or the user can query the execution result independently. It can be seen that the above requirements are traditional applications can not do, so the task scheduling system is needed to achieve it.
Why develop a separate scheduling system?
From the perspective of Java technology, there are many ways to implement scheduled tasks, such as Timer, ScheduledExecutor, Quartz. No matter which way, it is easy to integrate the function of scheduled tasks in a project, without developing the project separately. Then why do we put forward the idea of task scheduling system when designing the system?
It is necessary to analyze the characteristics of information system first. First, information system is decentralized from the perspective of functional design, that is, a project or module usually only completes one thing, we need to design many, many applications to meet user needs. Taking ERP as an example, ERP contains a series of modules or systems such as planning and budget, order management, inventory management and financial management. All of these systems are directly related to business, so no system can be separated from the function of planning tasks. If the above methods are followed, It is essential that we integrate a complete set of planning task components into each project to meet our needs. Not only is this more difficult to develop, but it also leads to an exponential increase in maintenance or extension complexity. So the independent task scheduling system came into being.
Discussion on design ideas
So how do we design this system? Let’s focus on a few points.
1. Unified and flexible task configuration
(1) Task implementation is configurable: the specific logic of the task can be realized through methods or stored procedures, and different task requirements can be customized according to different parameters through configuration.
(2) Scheduled execution configuration: after defining the task logic, we need to configure the execution logic, which time to execute, whether fixed time or cycle, when to start or end, single execution or multiple execution need detailed configuration.
(3) Thread configuration: tasks need to be executed synchronously or asynchronously, daemons or non-daemons. The exception handling mechanism must be configured separately.
(4) Task flow configuration: Sometimes we need to execute not only one task, but a series of tasks, and the execution of the tasks is in sequence. At this time, we can connect the configured tasks into a process to execute them.
2. Easy task initiation and feedback
(1) Start tasks: After all tasks are configured, we need to start tasks. It is the best choice to start tasks through API.
(2) Feedback mechanism: There should be a feedback mechanism for the execution effect of the task to the user, which can be notified to the user, direct callback or reverse write.
3. Monitor task execution and log tracking
(1) Task monitoring: The execution process of a task is not smooth and may be successful, or there may be abnormal execution, unexpected termination, manual termination, etc. Therefore, the execution status of the task needs to be displayed according to the execution status of the task, and users can restart or continue the task as required.
(2) log tracking: if the re-execution is still unable to succeed, then most of the program must be abnormal, so the log record is essential, so that maintenance personnel can handle problems and solve problems according to the log.
Distribution
When the development of a task scheduling system is completed, with the increase of the frequency of use, there will be bottlenecks, so we will consider the deployment of multiple task scheduling systems to form a distributed, but the deployment of multiple systems, will involve registry, load, routing, data synchronization and other problems. This paper only discusses how to design the function of task scheduling system, and does not involve the idea of distributed scheduling. I don’t want to talk about it here, but just throw out a brick to introduce jade, interested friends can explore.
Afterword.
If you are interested in what we are doing with open source software, you are welcome to cooperate in any form, as a contributor or join us directly! Let’s build a set of open source information solutions together.
[code cloud] or [GitHub] search “Red Dragon ERP” click the star, you can also join us! Let’s start small and do something great! Communicate with developers kZCA2000