CN-121979571-A - Device instruction life cycle management method based on RabbitMQ plug and play
Abstract
The invention relates to the technical field of the Internet of things, in particular to a device instruction life cycle management method based on RabbitMQ plug-and-play, which comprises the following steps of constructing an intermediate plug-in based on RabbitMQ to manage the creation, issuing and response of a device instruction; the method comprises the steps of obtaining incomplete instructions of the same batch according to batch inquiry, calculating the maximum execution time of the incomplete instructions of the same batch, dynamically creating multiple queues, issuing the instructions to the equipment according to the multiple queues, adjusting the multiple queues in the process of issuing the instructions, recovering the dynamic queues after the equipment response is successful according to the response condition of the equipment after the instruction execution is completed, and continuing to execute the instructions when the equipment response is failed. The device instruction life cycle management method based on RabbitMQ plug and play can be suitable for various Internet of things devices, completely covers the whole life cycle of the instruction, achieves high-performance and high-concurrency execution of the instruction, and has a fault-tolerant mechanism.
Inventors
- HUANG JIALIANG
- LIN SHAOYU
- ZHANG YU
- HUANG SHI
- FANG TAO
- WEI SHENG
- CHEN ZHIHONG
- TAO WEIJIAN
Assignees
- 广西壮族自治区公众信息产业有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251218
Claims (10)
- 1. The device instruction life cycle management method based on RabbitMQ plug and play is characterized by comprising the following steps: S1, constructing an intermediate plug-in based on RabbitMQ to manage creation, issuing and response of equipment instructions; s2, for equipment with incomplete instructions, obtaining the incomplete instructions of the same batch according to batch inquiry, and calculating the maximum execution time in the incomplete instructions of the same batch; S3, dynamically creating multiple queues according to the maximum execution time of each batch and the instruction number of the batch and according to the operation parameters of a server, issuing instructions to the equipment according to the multiple queues, and adjusting the multiple queues according to the state of the multiple queues and the operation state of the server in the instruction issuing process; S4, after the instruction execution is completed, according to the response condition of the equipment, recovering the dynamic queue after the equipment response is successful, and continuing to execute the instruction when the equipment response is failed.
- 2. The method for managing the lifecycle of the device command based on the plug and play of RabbitMQ according to claim 1, wherein in step S2, it is determined whether there is an incomplete command according to the serial number of the device.
- 3. The method for managing the instruction lifecycle of a RabbitMQ plug and play based device according to claim 1, wherein in step S2, the device is capable of executing simultaneously, assuming that the instruction execution order is not optimized and the execution times are independent in the worst case Instructions arranged in descending order of execution time T 1 ≥t 2 ≥…≥t n , the maximum execution time calculation method in the same batch of incomplete instructions is as follows: formula (1) Wherein, the Maximum execution time in outstanding instructions for the same batch; Batch times; Is the first Execution time of the longest instruction in the batch.
- 4. The method of claim 3, wherein in step S2, the device is provided with a time lock, the time lock is equal to the maximum execution time of the same batch of outstanding instructions, so that the device can completely execute the instructions within the time of the time lock, and the device receives a dynamic queue after the time lock arrives.
- 5. The method for managing the lifecycle of the device command based on RabbitMQ plug and play according to claim 1, wherein in step S3, the operation parameters of the server include a CPU core number of the server and a memory of the server.
- 6. The method for managing the service life of the device command based on the RabbitMQ plug and play according to claim 1, wherein in step S3, the number of the queues to be dynamically created is calculated, and then the number of the queues is evenly distributed to each queue according to the command, and the commands of the queues are issued to the device.
- 7. The method for managing the lifecycle of the device command based on RabbitMQ plug and play according to claim 6, wherein in step S3, the number of queues dynamically created for optimal use is calculated with the shortest time to process the command as a target: formula (2) Wherein, the The number of queues created for optimal required dynamics; is the maximum number of queues; For theoretically optimal queue quantity, each instruction corresponds to one queue; maximum execution time in outstanding instructions for the same batch; For a target processing time threshold, it is defined based on traffic demand or SLA.
- 8. The method of claim 7, wherein in step S3, when there is no specific target processing time threshold, the number of queues corresponding to the theoretical minimum total processing time is calculated.
- 9. The method for managing the lifecycle of the device command based on the RabbitMQ plug and play according to claim 7, wherein in step S3, the optimal total processing time is calculated according to the optimal number of queues required to be dynamically created: Formula (3) Wherein, the Is the optimal total processing time; The number of queues created for optimal required dynamics; For theoretically optimal queue quantity, each instruction corresponds to one queue; the maximum execution time in outstanding instructions for the same batch.
- 10. The method for managing the device instruction lifecycle based on RabbitMQ plug and play according to claim 1, wherein in step S4, when the device response is successful after the instruction execution is completed, subtracting 1 from the number of executing instructions, and judging whether the number of instructions to be executed and the number of instructions being executed are equal to 0, if the number of instructions to be executed and the number of instructions being executed are both 0, recovering all dynamic queues, and releasing performance to the next batch of instructions; And when the response of the equipment fails, judging whether a preset executing instruction exit condition is reached, if the preset executing instruction exit condition is not reached, continuing to execute, and if the executing instruction exit condition is reached, exiting the instruction and recovering the queue release performance.
Description
Device instruction life cycle management method based on RabbitMQ plug and play Technical Field The invention relates to the technical field of the Internet of things, in particular to a device instruction life cycle management method based on RabbitMQ plug and play. Background Along with the continuous wide application of the internet of things technology in various industries, the types of devices accessed by the internet of things platform are increased, such as access control machines, consumer machines, public phones, train locks, electronic student certificates and the like, and corresponding instructions need to be issued from the platform when the devices execute corresponding operations. In the prior art, multithreading is mainly adopted to treat concurrent conditions, and the lifecycle management of instructions is often tightly interleaved with platform business logic and lacks independence. Specifically, when each device type is accessed to the platform, a set of instruction issuing mechanism needs to be independently developed, including links such as packaging, transmission, analysis, execution, feedback and the like of the instruction. The distributed implementation not only results in repeated development of a large number of functions and increases the complexity and cost of system maintenance, but also causes the instruction execution flow to lack unified standards and specifications, and is difficult to ensure consistency and reliability. More seriously, the highly coupled design forms a close dependency relationship between the instruction management function and the platform business logic, and the modification of any party can have unpredictable influence on the other party, thereby greatly limiting the flexibility and the expandability of the system. In the case of the service peak period, such as the service peak period of student eating consumption, entrance guard of school and the like in a campus scene, if a large amount of instructions are issued at this time, the main service usage is affected, and the instruction issuing efficiency is also affected. The method is characterized in that the current instruction issuing is carried out by using multithreading in a service, the method is only suitable for one device, the whole life cycle of the instruction is doped in the service, each device service realizes the instruction issuing function, so that repeated development, randomness range, high coupling and no plug and play effect are realized, the instruction with failed execution can be directly discarded, the processing is too rough, the instruction can be issued in batches in order, the subsequent instruction can be issued after the instruction is responded, for example, the positioning device can acquire positioning information for too long time, and the issuing speed of other instructions can be blocked. Disclosure of Invention In order to solve the problems, the invention provides a device instruction life cycle management method based on RabbitMQ plug and play, which can be adapted to various Internet of things devices, completely covers the whole life cycle of instructions, achieves high-performance and high-concurrency execution of the instructions, and has a fault-tolerant mechanism. In order to achieve the above purpose, the technical scheme adopted by the invention is as follows: the device instruction life cycle management method based on RabbitMQ plug and play comprises the following steps: S1, constructing an intermediate plug-in based on RabbitMQ to manage creation, issuing and response of equipment instructions; s2, for equipment with incomplete instructions, obtaining the incomplete instructions of the same batch according to batch inquiry, and calculating the maximum execution time in the incomplete instructions of the same batch; S3, dynamically creating multiple queues according to the maximum execution time of each batch and the instruction number of the batch and according to the operation parameters of a server, issuing instructions to the equipment according to the multiple queues, and adjusting the multiple queues according to the state of the multiple queues and the operation state of the server in the instruction issuing process; S4, after the instruction execution is completed, according to the response condition of the equipment, recovering the dynamic queue after the equipment response is successful, and continuing to execute the instruction when the equipment response is failed. Further, in step S2, it is determined whether there is an incomplete instruction according to the serial number of the device. Further, in step S2, in the worst case, the device can execute simultaneously, assuming that the instruction execution order is not optimized and the execution times are independentInstructions arranged in descending order of execution timeT 1≥t2≥…≥tn, the maximum execution time calculation method in the same batch of incomplete instructions is as foll