A service configuration method and device for internet of things
The combination of distributed timers and rule engines solves the problems of poor disaster recovery and difficult maintenance of rule description files in IoT systems. It also achieves the extraction of rule engines and a user-friendly configuration interface, improving business configuration performance and user experience.
Patent Information
- Application Number
- CN202211619284.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2042-12-14
AI Technical Summary
The rule description files in the IoT system have poor disaster recovery capabilities in distributed, highly available Internet scenarios, are difficult to maintain, and users cannot flexibly configure them, resulting in a low user experience.
A combination of distributed timers and rule engines is adopted. Distributed timers are used to trigger rules, and rule execution nodes are selected through preset routing strategies. Message middleware such as Kafka is used to obtain device data streams, trigger conditions are stored in Redis middleware, and rule content is stored in a MySQL database. A user-friendly configuration interface is provided to separate the rule engine from the business code.
It improves the disaster recovery capability of rule description files, reduces maintenance difficulty, improves user configuration flexibility and experience, and enhances business configuration performance.
Smart Images

Figure CN116032749B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of Internet of Things, and in particular to a service configuration method and device for the Internet of Things. Background Art
[0002] Currently, rule description files in IoT systems are often generated locally on business nodes. This presents significant drawbacks in distributed, highly available Internet scenarios, resulting in poor disaster recovery capabilities. Furthermore, rule description files are generated at business nodes and are highly coupled to the business, posing challenges for subsequent maintenance. Summary of the Invention
[0003] The embodiments of the present application provide a service configuration method and device for the Internet of Things, which is used to solve the problems that the current rule description file has poor disaster recovery capability and is difficult to maintain. Under multiple service nodes, users cannot flexibly configure the file, resulting in a low user experience.
[0004] In one aspect, an embodiment of the present application provides a service configuration method for the Internet of Things, the method comprising:
[0005] Obtain a rule trigger instruction for a distributed timer. Based on the rule trigger instruction, determine the device data stream of the corresponding IoT device. Match the device data stream with the corresponding trigger condition, and determine whether the corresponding rule content matches based on the matching result. The rule content is pre-stored in a preset first database. The trigger condition and rule content are configured by the user terminal. If so, trigger the rule engine to execute the corresponding rule content, thereby sending the control instruction configured by the user terminal to the IoT device.
[0006] In one implementation of the present application, a preset routing strategy for a distributed timer is determined. The preset routing strategy includes at least: selecting the first execution node, selecting the last execution node, random selection, round-robin selection, and consistent hashing. Based on the preset routing strategy, a corresponding rule execution node is determined.
[0007] In one implementation of the present application, when a rule triggering instruction meets corresponding preset conditions, the device data stream of the Internet of Things device corresponding to the rule triggering instruction is obtained through the preset message middleware.
[0008] In one implementation of the present application, the message middleware is Kafka.
[0009] In one implementation of the present application, the device data stream is input into the second database to match the trigger condition in the second database.
[0010] In one implementation of the present application, the second database is Redis.
[0011] In one implementation of the present application, the first database is MySQL.
[0012] In one implementation of the present application, the rule engine is Drools.
[0013] In one implementation of the present application, a trigger condition configuration interface, a rule content configuration interface, and a control instruction configuration interface are displayed on a user terminal. Trigger conditions, rule content, and control instructions are generated based on user operations on the user terminal. These operations include at least clicking a drop-down bar, entering attribute values, adding items, and deleting items.
[0014] On the other hand, an embodiment of the present application provides a service configuration device for the Internet of Things, the device comprising:
[0015] At least one processor; and a memory communicatively connected to the at least one processor. The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0016] Obtain a rule trigger instruction for a distributed timer. Based on the rule trigger instruction, determine the device data stream of the corresponding IoT device. Match the device data stream with the corresponding trigger condition, and determine whether the corresponding rule content matches based on the matching result. The rule content is pre-stored in a preset first database. The trigger condition and rule content are configured by the user terminal. If so, trigger the rule engine to execute the corresponding rule content, thereby sending the control instruction configured by the user terminal to the IoT device.
[0017] Through the above-mentioned scheme, the present application can use distributed timers to trigger rules and determine whether the device data flow meets the triggering conditions. If so, the rule engine is used to execute the rule content stored in the first database, thereby realizing the extraction of the rule engine from the business code and reducing the difficulty of maintaining the rule description file of the rule engine; and the distributed storage technology of the distributed timer and the storage of the triggering conditions in the Redis middleware can process transactions on multiple nodes, improve business configuration performance, and improve the disaster recovery capability of the rule content (rule description file).
[0018] In addition, this application can provide a user-friendly background management interface for the user terminal, through which non-technical personnel can flexibly configure the rule content, thereby reducing the difficulty of configuring the rule content of the IoT device and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 A flowchart of a service configuration method for the Internet of Things in an embodiment of the present application is provided;
[0021] Figure 2 This is a schematic diagram of execution logic in a service configuration method for the Internet of Things in an embodiment of the present application;
[0022] Figure 3 This is a schematic diagram of a configuration interface in a service configuration method for the Internet of Things in an embodiment of the present application;
[0023] Figure 4 This is a structural diagram of a service configuration device for the Internet of Things in an embodiment of the present application. DETAILED DESCRIPTION
[0024] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0025] In distributed scenarios, to ensure disaster recovery, performance, and other issues, business nodes are generally deployed in a multi-active (multi-node, multi-network environment) configuration. Since the rule description files of the rule engine are stored in file form, the rule description files we generate according to the rules will be generated locally on a certain business node. This has a significant disadvantage (single point problem) in distributed, highly available Internet scenarios. Similarly, rule files are generated on business nodes and are highly coupled with the business, making subsequent expansion and maintenance more difficult. Rule files are stored in code form, which is difficult for non-professionals to understand, and there is no visual interface, resulting in poor readability.
[0026] Based on this, the embodiments of the present application provide a service configuration method and device for the Internet of Things to solve the above problems.
[0027] The following describes in detail various embodiments of the present application with reference to the accompanying drawings.
[0028] The present application embodiment provides a service configuration method for the Internet of Things, such as Figure 1 As shown, the method may include steps S101-S104:
[0029] S101: The server obtains a rule triggering instruction of a distributed timer.
[0030] It should be noted that the server is an execution subject of the service configuration method for the Internet of Things, and only serves as an example. The execution subject is not limited to the server, and the present application does not make a specific limitation thereon. The method is preferably executed by a server cluster.
[0031] In the embodiment of the present application, after the server obtains the rule trigger instruction of the distributed timer, the method further comprises:
[0032] First, the preset routing strategy of the distributed timer is determined. The preset routing strategy at least includes: selecting the first execution node, selecting the last execution node, random selection, polling selection, consistent hash. Then, the corresponding rule execution node is determined according to the preset routing strategy.
[0033] The rule execution node can be a server in the server cluster, and the preset routing strategy can include selecting the first execution node, selecting the last execution node, random selection, polling selection, consistent hash, least frequently used, least recently used, failover, busy transfer, distribution broadcast, etc. The server is selected for execution trigger condition.
[0034] The timer of the present application is distributed, thereby improving the concurrent performance of service configuration, and the nodes of extended service configuration are easier to expand.
[0035] S102, the server determines the device data stream of the corresponding Internet of Things device according to the rule trigger instruction.
[0036] In the embodiment of the present application, the server determines the device data stream of the corresponding Internet of Things device according to the rule trigger instruction, which specifically comprises:
[0037] In the case that the rule trigger instruction meets the corresponding preset condition, the device data stream of the Internet of Things device corresponding to the rule trigger instruction is obtained through the preset message middleware.
[0038] In an embodiment of the present application, the message middleware is preferably Kafka.
[0039] The preset condition is a condition for determining whether the rule trigger instruction can be executed. For example, if the preset condition is to execute the rule trigger instruction at 6 o'clock every day, then before 6 o'clock on the same day, the rule trigger instruction cannot meet the preset condition, and until 6 o'clock, the rule trigger instruction meets the preset condition, and the step of obtaining the device data stream can be executed.
[0040] In addition, the server inputs the device data stream to the second database to match the trigger condition in the second database. The second database is preferably Redis.
[0041] For example, Figure 2The business configuration execution logic flow chart is shown, the trigger condition is stored in Redis, the device data stream is taken as the input parameter, and the trigger condition in Redis is matched, which can improve the efficiency of data processing and improve the performance of business configuration. The trigger condition is configured through the interface of the user terminal, stored in Redis, and matched with the input parameter of the device data stream to call and execute the trigger condition matched with the input parameter. For example, the device data stream of the street lamp is taken as the input parameter, and then the trigger condition of the street lamp can be matched.
[0042] In S103, the server matches the trigger condition corresponding to the device data stream to determine whether the corresponding rule content is matched according to the matching result.
[0043] The rule content is pre-stored in a preset first database. The trigger condition and the rule content are configured by the user terminal.
[0044] The first database is MySQL. The rule engine is Drools.
[0045] In Drools, rules are stored in Production Memory (rule base), and facts (facts) to be matched by the inference engine are stored in Working Memory (working memory). When the facts are inserted into the working memory, the rule engine matches the facts with the patterns in the rule base. For the matched rules, the Agenda component is responsible for executing the rule conclusion part triggered in the specific inference algorithm, and the Agenda manages the execution order of the conflicting rules through the conflict resolution strategy. The rule content of Drools is stored in the form of a file.
[0046] In addition, before the server matches the trigger condition corresponding to the device data stream, the method further comprises:
[0047] Firstly, the server displays the trigger condition configuration interface, the rule content configuration interface and the control instruction configuration interface on the user terminal.
[0048] The trigger condition configuration interface, the rule content configuration interface and the control instruction configuration interface are displayed on the interface of the user terminal, as shown in Figure 3 .
[0049] Then, the server generates the trigger condition, the rule content and the control instruction based on the operation of the user terminal by the user. The operation at least includes drop-down column clicking, attribute value input, item adding and item deleting.
[0050] The user can perform drop-down column clicking, attribute value input or item adding or deleting on the user terminal to select different trigger conditions, judgment conditions (rule content) and execution actions (control instructions).
[0051] By triggering the matching of the condition, the amount of data can be degraded, and the data throughput can be improved.
[0052] In S104, the server determines that the corresponding rule content is matched, triggers the rule engine to execute the corresponding rule content, so as to send the control instruction configured by the user terminal to the Internet of Things device.
[0053] That is, the server can match the rule content, call the rule engine Drools to execute the rule content, and according to the configured execution action, call the application program for controlling the Internet of Things device to perform the corresponding business. The business includes: sending a short message, sending an email, starting and stopping a rule.
[0054] The Internet of Things device is, for example, a street lamp, a camera, a sweeping robot, and the like. The specific type of the Internet of Things device is not limited in the present application.
[0055] The above-mentioned scheme can be used to trigger rules by using a distributed timer, to determine whether the device data stream meets the triggering condition, and if so, to execute the rule content stored in the first database by using the rule engine, thereby realizing the separation of the rule engine from the business code, reducing the maintenance difficulty of the rule engine, and using the distributed storage technology to store the triggering condition in the Redis middleware, to process transactions in multiple nodes, improve the business configuration performance, and improve the disaster recovery capability.
[0056] In addition, the present application can provide a user-friendly background management interface for the user terminal. Non-technical personnel can edit the rule content by using the interface, thereby reducing the difficulty of configuring the rule content of the Internet of Things device and improving the user experience.
[0057] Figure 4 A business configuration device for the Internet of Things is provided in the embodiments of the present application, and the device comprises:
[0058] at least one processor; and a memory connected in communication with the at least one processor. The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to:
[0059] obtain a rule triggering instruction of a distributed timer. According to the rule triggering instruction, determine the device data stream of the corresponding Internet of Things device. Match the triggering condition corresponding to the device data stream, to determine whether the corresponding rule content is matched according to the matching result. The rule content is pre-stored in a preset first database. The triggering condition and the rule content are configured by the user terminal. If so, trigger the rule engine to execute the corresponding rule content, so as to send the control instruction configured by the user terminal to the Internet of Things device.
[0060] The various embodiments herein are described in progressive manner, and the same or similar parts among the various embodiments can be referred to each other, and each embodiment focuses on the difference from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiments.
[0061] The device and the method provided by the embodiments of the present application are one-to-one correspondence, therefore, the device also has the similar beneficial technical effects as the method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the device will not be repeated here.
[0062] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or includes elements inherent to such a process, method, article or device. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of other identical elements in the process, method, article or device comprising the element.
[0063] The above only describes the embodiments of the present application and is not intended to limit the present application. The present application can have various modifications and changes for those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application shall be included in the scope of claims of the present application.
Claims
1. A service configuration method for the Internet of Things, characterized in that: The method comprises: Get the rule triggering instructions of the distributed timer; Triggering instructions according to the rules to determine the device data flow of the corresponding IoT device; Matching the trigger conditions corresponding to the device data flow to determine whether the corresponding rule content is matched according to the matching result; wherein the rule content is pre-stored in a preset first database; the trigger conditions and the rule content are configured by the user terminal; If so, triggering the rule engine to execute the corresponding rule content so as to send the control instruction configured by the user terminal to the IoT device; The method of triggering the instruction according to the rule to determine the device data flow of the corresponding IoT device specifically includes: When the rule trigger instruction satisfies the corresponding preset conditions, the device data stream of the IoT device corresponding to the rule trigger instruction is obtained through the preset message middleware; the IoT device includes: street lights, cameras, and sweeping robots; the preset conditions are conditions for determining whether the rule trigger instruction can be executed; Wherein, the message middleware is Kafka; Before matching the trigger condition corresponding to the device data flow, the method further includes: Displaying the trigger condition configuration interface, the rule content configuration interface, and the control instruction configuration interface on the user terminal; generating the trigger condition, the rule content, and the control instruction based on the user's operation on the user terminal; the operation at least includes clicking on a drop-down bar, inputting an attribute value, adding an item, and deleting an item; After obtaining the rule triggering instruction of the distributed timer, the method further includes: Determine a preset routing strategy for the distributed timer; wherein the preset routing strategy includes at least: selecting the first execution node, selecting the last execution node, random selection, round-robin selection, and consistent hashing; Determine the corresponding rule execution node according to the preset routing strategy; The method further comprises: Input the device data stream into a second database to match the trigger condition in the second database; the second database is Redis; the trigger condition is stored in Redis, and the device data stream is used as an input parameter and input into Redis to match the trigger condition in Redis; the trigger condition is configured through the user terminal interface, stored in Redis, and after matching the input parameter of the device data stream, it is called to execute the trigger condition that matches the input parameter; The rule engine is Drools. In Drools, rules are stored in a rule base, and facts to be matched by the inference engine are stored in the working memory. Once facts are inserted into the working memory, the rule engine matches the facts with the patterns in the rule base. For successfully matched rules, the Agenda component is responsible for executing the rule conclusions that are triggered in the specific inference algorithm. At the same time, the Agenda component manages the execution order of these conflicting rules through a conflict resolution strategy. Drools rule content is stored in the form of files. When the server matches the rule content, it calls the rule engine Drools to execute the rule content, and calls the application that controls the IoT device according to the configured execution action to perform the corresponding business.
2. The method according to claim 1, characterized in that The first database is MySQL.
3. A service configuration device for the Internet of Things, characterized in that: The device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the service configuration method for the Internet of Things as described in any one of claims 1-2 above.
Citation Information
Patent Citations
Behavior data response method and device, computer equipment and storage medium
CN110610376A