Business processing method based on thread pool management

By adopting a business processing method based on thread pool management in the power Internet of Things, integrating public basic services and setting up a unified message interface, the problem of long development cycle and low efficiency of power equipment under different services is solved, and a unified business message processing method and efficient business processing efficiency is achieved.

CN120029678APending Publication Date: 2025-05-23XUCHANG XJ SOFTWARE TECHNOLOGIES LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311556772.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-21
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

During the construction of the power Internet of Things, power equipment has a long development cycle, low efficiency and lacks a unified process processing method under different businesses.

Method used

The business processing method based on thread pool management is adopted, and the public basic services of the power Internet of Things are integrated as the basic service framework, and a unified message interface is set up. The basic service framework is used for log initialization, user service dynamic link library loading, communication initialization and thread pool initialization to form a unified business message processing method.

Benefits of technology

Through a unified basic service framework and thread pool management, the execution efficiency of business processing is improved, the development cycle is shortened, a unified process processing method is formed, and the efficiency of power Internet of Things business processing is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029678A_ABST
    Figure CN120029678A_ABST
Patent Text Reader

Abstract

The invention relates to a service processing method based on thread pool management, and belongs to the technical field of Internet of Things. According to the method, firstly, public basic services of the power Internet of Things are integrated into a basic service framework, a unified message interface is set for the basic service framework for a user to develop services, when a user application is started, service initialization is carried out, and after initialization is finished, periodic operation is carried out, and service message processing is carried out; and when it is detected that the number of messages needing to run in the thread pool exceeds an expected value, early backlog messages in the thread pool are cleared. According to the invention, based on the basic service framework of the power Internet of Things, the thread pool is uniformly adopted to schedule and manage service processing, and when the number of messages in the thread pool is detected to exceed an expected value, earlier backlog messages are cleared, so that excessive backlog of the messages caused by massive messages and influence on normal message processing are prevented, the execution processing efficiency of the service is improved, and the user experience is improved. And the security, fault tolerance and stability of the application are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a business processing method based on thread pool management, belonging to the technical field of Internet of Things. Background Art

[0002] The power Internet of Things is the application of the Internet of Things in the smart grid. It is the result of the development of information and communication technology to a certain stage. It will effectively integrate communication infrastructure and power system infrastructure resources, improve the level of informatization of the power system, improve the utilization rate of the existing infrastructure of the power system, and provide important technical support for the power grid's generation, transmission, transformation, distribution, and consumption.

[0003] In the process of building the power Internet of Things, it is necessary to manage and access a large number of heterogeneous terminals through software definition. Currently, the application of Internet of Things technology in the power industry is still in its early stages. Power equipment operates in different businesses, and each business developer develops code according to relevant standards and specifications, using their own independent functional service processing methods. There is no unified process processing method, resulting in a long development cycle and low efficiency. Summary of the invention

[0004] The purpose of the present invention is to provide a business processing method based on thread pool management to solve the problems of long development cycle and low efficiency in the business processing process.

[0005] In order to solve the above technical problems, the present invention provides a business processing method based on thread pool management, which comprises the following steps:

[0006] 1) Integrate the public basic services of the power Internet of Things into a basic service framework, and set a unified message interface for the basic service framework for user business development services. The public basic services include log services, communication services, user profile parsing services, business module loading services, and message receiving and sending services;

[0007] 2) After the user service is started, the basic service framework is used to initialize the log, parse the read configuration file, obtain the user configuration information, and use the parsing result to load the user service dynamic link library;

[0008] 3) After the user service dynamic link library is successfully loaded, communication initialization and thread pool initialization are performed. When the thread pool is initialized, the number of threads needs to be determined according to the user configuration information obtained by parsing;

[0009] 4) After initialization, the process starts to run periodically, and business messages are processed according to the number of threads determined when the thread pool is initialized.

[0010] The present invention first integrates the basic service framework, sets a unified message interface, performs log initialization service to load the user service dynamic link library based on the basic service framework after the user service is started, and then performs communication initialization and thread pool initialization. After the initialization interpretation, the service message processing is performed according to the number of threads obtained by the thread pool initialization. The present invention adopts a unified basic service framework and sets a unified message interface to form a unified service message processing method. By loading the user service dynamic link library, there is no need to develop basic public services separately, thereby improving the execution processing efficiency of the service.

[0011] Furthermore, the thread pool includes a monitoring thread for detecting the running time of each thread executing a task. When it is detected that a thread has timed out, the thread will be killed, and then a new thread will be created and added to the thread pool.

[0012] Furthermore, the method also includes performing communication monitoring during the periodic operation period, and re-initiating the communication connection if a communication disconnection is found.

[0013] Communication monitoring can detect communication connection problems in time and reconnect them.

[0014] Furthermore, the business message processing refers to executing the messages sent by users in real time and the messages processed in a fixed period through periodic operation, adding the messages to the thread pool and waiting for thread scheduling. The number of messages running in the current thread pool will be detected during the operation of the main program of the basic service framework.

[0015] Furthermore, the method also includes clearing out older backlog messages in the thread pool when it is detected that the number of messages that need to be run in the thread pool exceeds an expected value.

[0016] Clear the older backlog messages in the thread pool to prevent massive messages from causing excessive message backlogs and affecting normal message processing.

[0017] Furthermore, the business messages include real-time messages sent by users and periodic messages.

[0018] Furthermore, the real-time messages sent by users are differentiated and processed according to the Topic; periodic messages are used for periodic data collection and periodic monitoring of device status. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a flow chart of the business processing method based on thread pool management of the present invention;

[0020] Figure 2 is a flowchart of thread pool management in an embodiment of the present invention;

[0021] Figure 3 It is a unified message interface definition diagram in an embodiment of the present invention. DETAILED DESCRIPTION

[0022] The specific implementation of the present invention will be further described below in conjunction with the accompanying drawings.

[0023] Embodiment of a business processing method based on thread pool management

[0024] The present invention first integrates the public basic services of the electric power Internet of Things into a basic service framework, and sets a unified message interface for the basic service framework for user business development services. The public basic services include log services, communication services, user configuration file parsing services, business module loading services, and message receiving and sending services. After the user business is started, the basic service framework is used to initialize the log, and the read configuration file is parsed to obtain user configuration information, and the user business dynamic link library is loaded using the parsing result. After the user business dynamic link library is successfully loaded, communication initialization and thread pool initialization are performed. When the thread pool is initialized, the number of threads needs to be determined according to the user configuration information obtained by parsing. After the initialization is completed, the cycle operation is entered, and business message processing is performed according to the number of threads determined when the thread pool is initialized. The implementation process of this method is as follows: Figure 1 As shown, the following is explained with reference to specific examples.

[0025] The thread pool management process is as follows Figure 2 As shown, when the system is initialized, the number of threads in the thread pool is set according to the user configuration file. The thread pool main program starts a monitoring thread, which periodically detects the running time of each thread executing a task. When a thread is detected to have timed out, the thread is killed, and then a new thread is created and added to the thread pool to ensure that the number of threads in the thread pool is consistent with the number of threads set in the user configuration file.

[0026] The basic service framework is mainly used to provide basic public services for user services, including log services, communication services, user profile parsing services, business module loading services, and message receiving and sending services. User services develop services based on the unified message interface definition provided by the basic service framework and generate a user service dynamic link library so. The unified message interface definition is as follows: Figure 3 shown.

[0027] When the user application starts, the basic service framework first initializes the log service, parses the various settings of the user configuration file, loads the user business dynamic link library so according to the specified directory in the user configuration file, and then initializes the communication service, initializes the number of threads in the thread pool, and executes the startup initialization function of the application. After the initialization is completed, it enters the cycle operation period. During the operation of the application, the main program of the basic service framework will monitor the communication status. If the communication is disconnected, it will re-initiate the communication connection. After the communication connection is normal, it will process the message, execute the user's real-time messages and the fixed-cycle processed messages respectively, and add the messages to the thread pool to wait for thread scheduling; each time the main program of the basic service framework runs, it will detect the number of messages that need to be run in the current thread pool in the process of processing the user's real-time messages; when it is detected that the number of messages that need to be run in the thread pool exceeds the expected value, the older backlog messages in the thread pool will be cleared to prevent massive messages from causing excessive backlogs and affecting normal message processing.

[0028] The process of generating the dynamic link library is as follows: set the header file search path and the dependent lib library path in the CMakeLists.txt file of the user business project, use add_library to set the name of the dynamic link library when it is generated and the project code file to be compiled, and use target_link_libraries to set the lib library that the project needs to link to. Finally, execute CMakeLists.txt through the cmake command to generate the corresponding user business dynamic link library file.

[0029] There are two types of messages processed during operation. One is the real-time message sent by the user, which is processed according to the topic; the other is the periodic message, which is generally used for periodic data collection and periodic monitoring of equipment status.

Claims

1. A business processing method based on thread pool management, It is characterized in that The method comprises the following steps: 1) Integrate the public basic services of the power Internet of Things into a basic service framework, and set a unified message interface for the basic service framework for user business development services. The public basic services include log services, communication services, user profile parsing services, business module loading services, and message receiving and sending services; 2) After the user service is started, the basic service framework is used to initialize the log, parse the read configuration file, obtain the user configuration information, and use the parsing result to load the user service dynamic link library; 3) After the user service dynamic link library is successfully loaded, communication initialization and thread pool initialization are performed. When the thread pool is initialized, the number of threads needs to be determined according to the user configuration information obtained by parsing; 4) After initialization, the process starts to run periodically, and business messages are processed according to the number of threads determined when the thread pool is initialized.

2. The business processing method based on thread pool management according to claim 1, It is characterized in that The thread pool includes a monitoring thread for detecting the running time of each thread executing a task. When it is detected that a thread has timed out, the thread will be killed, and then a new thread will be created and added to the thread pool.

3. The business processing method based on thread pool management according to claim 1 or 2, It is characterized in that The method also includes performing communication monitoring during the periodic operation period, and re-initiating the communication connection if a communication disconnection is found.

4. The business processing method based on thread pool management according to claim 1, It is characterized in that The business message processing refers to the execution of messages sent by users in real time and messages processed in fixed periods through periodic operation, and the messages are added to the thread pool waiting for thread scheduling. The number of messages running in the current thread pool is detected during the operation of the main program of the basic service framework.

5. The business processing method based on thread pool management according to claim 4, It is characterized in that The method also includes clearing out older backlog messages in the thread pool when it is detected that the number of messages that need to be run in the thread pool exceeds an expected value.

6. The business processing method based on thread pool management according to claim 1, It is characterized in that The business messages include real-time messages sent by users and periodic messages.

7. The business processing method based on thread pool management according to claim 6, It is characterized in that Messages sent by users in real time are differentiated and processed according to the Topic; periodic messages are used for periodic data collection and periodic monitoring of device status.