Method, device, server and storage medium for processing Internet of Things messages
By performing phased preprocessing and cache calls on IoT messages, the problem of low efficiency in IoT messages is solved, and efficient processing of massive IoT messages is achieved.
Patent Information
- Application Number
- CN202410895779.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-07-05
AI Technical Summary
In the prior art, the processing efficiency of IoT messages is low and cannot meet the high-performance processing needs of massive IoT messages.
By preprocessing more than 2 stages of IoT messages, the number of preprocessing stages is determined based on the data type required for the parsing operation, and the corresponding preprocessing cache is called based on the data type to perform the parsing operation, reducing the amount of data and complexity , improve analysis efficiency.
It effectively improves the processing efficiency of IoT messages, meets the high-performance processing needs of massive IoT messages, reduces data volume and complexity, and improves analysis efficiency.
Smart Images

Figure CN118612319B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of Internet of Things, and in particular, relates to a method for processing Internet of Things messages, an Internet of Things message processing device, a server and a computer-readable storage medium. Background Art
[0002] With the rapid development of IoT technology, the number of IoT devices is increasing, and the corresponding amount of data is also increasing rapidly. In this case, higher requirements are placed on the reception, transmission and parsing of IoT messages. In related technologies, the processing efficiency of IoT messages is relatively low, which cannot meet the high-performance processing requirements of massive IoT messages. Summary of the invention
[0003] The present application provides a method for processing Internet of Things messages, an Internet of Things message processing device, a server and a computer-readable storage medium, which can effectively improve the processing efficiency of Internet of Things messages to meet the high-performance processing requirements of massive Internet of Things messages.
[0004] In a first aspect, the present application provides a method for processing an Internet of Things message, comprising:
[0005] Before performing the parsing operation on the IoT message, the IoT message is preprocessed in more than two stages to obtain a preprocessing cache corresponding to each stage; the number of preprocessing stages is determined based on the data type required for the parsing operation; different data types correspond to different stages;
[0006] Based on the data type, the preprocessing cache of the corresponding stage is called to perform the parsing operation to obtain the parsing result.
[0007] In a second aspect, the present application provides an IoT message processing device, comprising:
[0008] A preprocessing module is used to preprocess the IoT message in more than two stages before performing a parsing operation on the IoT message to obtain a preprocessing cache corresponding to each stage; the number of preprocessing stages is determined based on the data type required for the parsing operation; different data types correspond to different stages;
[0009] The parsing module is used to call the preprocessing cache of the corresponding stage based on the data type to perform the parsing operation and obtain the parsing result.
[0010] In a third aspect, the present application provides a server comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method of the first aspect when executing the computer program.
[0011] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method of the first aspect are implemented.
[0012] In a fifth aspect, the present application provides a computer program product, which includes a computer program. When the computer program is executed by one or more processors, it implements the steps of the method of the first aspect.
[0013] Compared with the prior art, the present application has the following beneficial effects: considering that directly parsing the IoT message may cause difficulty in parsing due to the large amount and complexity of data, thereby reducing the processing efficiency of the IoT message. In order to improve the processing efficiency of the IoT message, the preprocessing stages that can be done before the formal parsing can be determined according to the data type required by the parsing process, and the IoT message is preprocessed in stages based on the determined number of stages to obtain the preprocessing cache corresponding to each stage. During parsing, the corresponding stage is determined according to the data type, and then the preprocessing cache of the corresponding stage is called to perform the parsing operation to efficiently complete the parsing operation and obtain the parsing result. Among them, the preprocessing cache obtained after the staged preprocessing has a smaller data volume and lower complexity than the IoT message. Parsing based on such data can effectively improve the processing efficiency of the IoT message to meet the high-performance processing requirements of massive IoT messages.
[0014] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0016] Figure 1 It is a flowchart of a method for processing Internet of Things messages provided in an embodiment of the present application;
[0017] Figure 2 It is a schematic flow chart of a two-stage pretreatment method provided in an embodiment of the present application;
[0018] Figure 3 It is a structural schematic diagram of a preprocessing method of three threads combined with two stages provided in an embodiment of the present application;
[0019] Figure 4It is a structural diagram of an Internet of Things message processing device provided in an embodiment of the present application;
[0020] Figure 5 It is a schematic diagram of the structure of the server provided in the embodiment of the present application. DETAILED DESCRIPTION
[0021] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0022] In the related technologies, the processing efficiency of IoT messages is relatively low, which cannot meet the high-performance processing requirements of massive IoT messages.
[0023] In order to solve this problem, the present application proposes a method for processing IoT messages, which can pre-process IoT messages in stages to ensure that the amount of data and complexity required to be processed during the formal parsing of IoT messages are significantly reduced, thereby effectively improving the processing efficiency of IoT messages. The control method proposed in the present application will be described below through specific embodiments.
[0024] The method for processing the Internet of Things message provided in the embodiment of the present application is mainly applied to a server, which can be a mobile phone, a tablet computer, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA) and other electronic devices. The embodiment of the present application does not impose any restrictions on the specific type of electronic device.
[0025] In order to illustrate the technical solution proposed in this application, each embodiment will be described below with the server as the execution entity.
[0026] Figure 1 A schematic flow chart of a method for processing an Internet of Things message provided by the present application is shown, and the method for processing an Internet of Things message includes:
[0027] Step 110: Before performing a parsing operation on the IoT message, the server preprocesses the IoT message in more than two stages to obtain a preprocessing cache corresponding to each stage.
[0028] After a series of parsing operations, the IoT message can get the corresponding parsing results. During the parsing process, the server can extract the data required for parsing from the IoT message, and then perform analysis and processing based on this data. If the IoT message is parsed directly, the server's processing efficiency of the IoT message may be reduced due to the large amount and complexity of the data contained in the IoT message, and it may not be able to meet the high-performance processing requirements of massive IoT messages.
[0029] In order to improve the processing efficiency of IoT messages, we can start from reducing the amount of data and reducing the complexity of data. Specifically, the server can first determine the required data type based on the data required for the parsing operation. Different types of data can be obtained in advance through different preprocessing, so a corresponding number of preprocessing stages can be designed. By preprocessing IoT messages at different stages, the preprocessing cache corresponding to each stage can be obtained, that is, the basic data for performing parsing operations can be obtained.
[0030] For example, see Figure 2 ,Assuming that the parsing process requires protocol data and device data, two preprocessing stages can be set accordingly, namely protocol parsing preprocessing and data extraction preprocessing. For each IoT message, two stages of preprocessing can be performed on it, namely protocol parsing and data extraction, and the cache of protocol data and device data can be obtained respectively.
[0031] Optionally, the same type of data may include different sub-data. When different sub-data need to be obtained through different preprocessing operations, corresponding sub-stages can be set for the stages corresponding to the type of data so that different sub-data can be pre-extracted as cache for server calls.
[0032] Optionally, in addition to setting the preprocessing stage based on the data type, conventional preprocessing operations may be added, such as unifying the data format and filtering redundant data, to further reduce the amount of data for parsing operations and reduce data complexity.
[0033] Step 120: The server calls the preprocessing cache of the corresponding stage based on the data type to perform the parsing operation and obtain the parsing result.
[0034] Different data types correspond to different preprocessing stages. Based on this, when the server is performing a parsing operation, it can call the preprocessing cache of the corresponding stage according to the correspondence between the data type and the stage, depending on which data type to parse. Among them, the preprocessing cache obtained after the staged preprocessing has a smaller data volume and lower complexity than the IoT message. Parsing based on such data can effectively improve the processing efficiency of the IoT message.
[0035] In this embodiment, in order to improve the processing efficiency of IoT messages, the server adopts a staged preprocessing method, first determines the preprocessing stage according to the data type required for parsing, and preprocesses the message to generate a preprocessing cache with small data volume and low complexity. During parsing, the server calls the corresponding preprocessing cache for parsing according to the data type, which can effectively reduce the amount and complexity of processed data and improve parsing efficiency.
[0036] In some embodiments, in order to process more IoT messages simultaneously and further improve the processing efficiency of IoT messages, the server can create a specified number of threads based on the central processing unit (CPU) that processes IoT messages, and each thread can process an IoT message independently.
[0037] Among them, no matter it is a single-core CPU or a multi-core CPU, the server can create multi-threading through a virtual machine, that is, map the set multiple threads to the operating system threads through the virtual machine.
[0038] In order to improve the processing efficiency of IoT messages based on multi-threading, the number of threads needs to be set reasonably.
[0039] Exemplarily, the server may create corresponding threads based on the number of physical cores of the CPU, thus avoiding the overhead caused by thread switching.
[0040] Exemplarily, the server may also determine the specified number based on the time required for the thread to process the task and the number of physical cores of the CPU.
[0041]
[0042] The specified number calculated by this formula ensures that at any given time, as many threads as possible are in the execution state rather than in the waiting state, thereby maximizing the use of CPU resources. By setting a specified number of threads, you can improve the system performance of the server in high-concurrency scenarios and avoid CPU idleness and resource waste.
[0043] In some embodiments, the multithreading created based on the above embodiments, before performing more than two stages of preprocessing on the IoT message, further includes:
[0044] Step A1: The server obtains the same number of IoT messages as the number of idle threads.
[0045] Step A2: The server matches each IoT message to each idle thread one by one.
[0046] Generally speaking, the number of IoT messages that can be processed simultaneously depends on the number of threads. However, as time goes by, some threads may be busy and some threads may be idle. Among them, the threads in the idle state can receive new IoT messages and process them. Such threads can be recorded as idle threads.
[0047] For example, assuming that three threads are created, the two-stage preprocessing is combined with the three-thread calculation. The processing diagram of the IoT message can be found in Figure 3 .
[0048] In order to fully call idle threads and avoid CPU idleness and resource waste, the server can first determine the number of idle threads and obtain the corresponding IoT messages to be processed based on the number. In other words, the number of IoT messages can be obtained according to the number of idle threads. Each idle thread processes at most one IoT message, so the server can correspond each idle thread to each IoT message one by one.
[0049] Step A3: The server returns to execute the aforementioned step 110 for each idle thread based on the corresponding Internet of Things message until the parsing result of the corresponding Internet of Things message is obtained.
[0050] For each idle thread, the process of processing the Internet of Things message is basically the same, the difference is that the processing object is different. The process of the idle thread processing the Internet of Things message is the step corresponding to the above-mentioned step 110 and step 120.
[0051] In an embodiment of the present application, the server can create multiple threads to allow more than one IoT message to be processed simultaneously, that is, by fully utilizing the CPU hardware resources to achieve batch processing of IoT messages, the processing efficiency of IoT messages can be further improved.
[0052] In some embodiments, when there are many IoT messages, all threads may be busy in a short period of time. In order to enable urgent messages to be processed efficiently, before performing more than two stages of preprocessing on the IoT messages, the following steps are also included:
[0053] Step B1: When the number of idle threads is 0, a message queue is constructed according to the received IoT message.
[0054] If the number of idle threads is 0, it means that all threads are busy processing other messages and there is no immediately available thread to process the newly received message. In order to avoid message loss, a message queue can be built based on IoT messages. Each IoT message in the message queue is a message to be processed.
[0055] In order to allow urgent messages to be processed efficiently and preferentially, each IoT message in the message queue can be arranged based on the priority level corresponding to the data type. And in order to facilitate message allocation, the message type corresponding to the IoT message at the head of the message queue has the highest priority level and the earliest timing.
[0056] Exemplarily, assume that the message types include alarm, measurement, and device status, among which alarm messages are important and urgent, so the priority of alarm messages is higher than that of other types of messages. Assume that 10 IoT messages are received, of which there is 1 IoT message corresponding to the alarm class, 5 IoT messages corresponding to the measurement class, and 4 IoT messages corresponding to the device status class. When constructing the message queue, the IoT message corresponding to the alarm class is placed at the head of the queue. For the remaining 9 messages, since the priority levels corresponding to their message types are the same, these 9 messages can be placed in the message queue in sequence.
[0057] Step B2: When the message type of the IoT message at the head of the queue is a specified type, the IoT message at the head of the queue is preferentially processed by the target thread.
[0058] The designated type is an important message type, which generally has a strong timeliness and needs to be processed in time. For example, alarm messages. Based on this, when the message type of the IoT message at the head of the queue is an alarm, for each busy thread, once a thread completes its task, the IoT message at the head of the queue can be assigned to the thread for processing, ensuring that important messages can be processed in a timely manner and improving the reliability of message processing.
[0059] In this embodiment, in order to optimize the processing of IoT messages, the server can build a message queue based on the IoT messages that have not been processed in time. This not only avoids the loss of IoT messages, but also allows important and urgent IoT messages to be at the head of the queue by setting an arrangement mechanism for the message queue. When allocating messages according to the message queue, they are allocated from the head of the queue, which can ensure that important and urgent IoT messages can be processed in time, thereby improving the reliability of IoT message processing.
[0060] In some embodiments, in addition to allocating IoT messages by constructing a message queue with a special arrangement mechanism, the following steps can also be used to ensure that urgent messages can be processed efficiently. Specifically, before performing more than two stages of preprocessing on IoT messages, the following steps are also included:
[0061] Step C1: The server constructs a common message channel and a priority message channel.
[0062] Step C2: The server pushes the first IoT message to the idle thread in sequence through a common message channel.
[0063] Step C3: The server pushes the second Internet of Things message or the first Internet of Things message to the idle thread in a time sequence through the priority message channel.
[0064] In order to reasonably allocate IoT messages to each idle thread and ensure that important and urgent IoT messages can be processed in a timely manner, the server can build two message channels, namely, the normal message channel and the priority message channel.
[0065] Different message channels can be used to push different IoT messages to idle threads. Specifically, the common message channel is mainly used to push IoT messages corresponding to non-urgent and important message types. For ease of description, this IoT message can be recorded as the first IoT message. The priority message channel is mainly used to push IoT messages corresponding to urgent and important message types, recorded as the second IoT message. Of course, for the priority message channel, the first IoT message can also be pushed without affecting the processing efficiency of the second IoT message.
[0066] In some embodiments, in different situations, the priority message channel can be used to push different IoT messages. Specifically, step C3 includes:
[0067] Step C31: If a second Internet of Things message is detected, the second Internet of Things message is pushed to the idle thread in a time sequence through the priority message channel.
[0068] Step C32: If the second Internet of Things message is not detected, the first Internet of Things message is pushed to the idle thread in a time sequence through the priority message channel.
[0069] Each received IoT message can be divided into a first IoT message and a second IoT message according to the corresponding message type. For the priority message channel, if there is a second IoT message in the received IoT message, the server can push the second IoT message with the earliest timing to the idle thread according to the timing of each second IoT message, so that important and urgent IoT messages can be processed in time.
[0070] However, if the second Internet of Things message does not exist in the received Internet of Things message, the server pushes the first Internet of Things message with the earliest sequence to the idle thread based on the sequence of the first Internet of Things messages.
[0071] In some embodiments, in order to ensure that the second IoT message with the earliest timing can be efficiently processed as much as possible, the server may further perform the following steps:
[0072] Step C311: If the residence time of the second IoT message in the priority message channel reaches a preset residence time threshold, the ordinary message channel is restricted from pushing the first IoT message to the idle thread, and the second IoT message data is preferentially pushed to the idle thread.
[0073] If the second IoT message in the priority message channel stays for a long time and has not been successfully pushed, for example, the stay time reaches a preset stay time threshold, such as 3s or 5s, the server can allocate a mandatory push right to the priority message channel, so that the corresponding second IoT message can be pushed in time, thereby ensuring its processing efficiency. Specifically, to limit the message push of the ordinary message channel, once there is an idle thread, the priority message channel can first push the second IoT message in the channel to the idle thread, and after the push is successful, restore the push permission of the ordinary message channel.
[0074] For example, assume that there are three message channels, one of which is a priority message channel. At time t, two ordinary message channels each have a first IoT message flowing into them, and at time t+1, the priority message channel has a second IoT message flowing into it. Since all threads are busy, the three IoT messages all stay in the corresponding message channels waiting to be pushed. At time t+3, the priority message channel obtains the right to force push. At time t+4, there is an idle thread, and the two ordinary message channels are restricted from pushing the corresponding first IoT message to the idle thread. The priority channel can push the second IoT message to the idle thread first.
[0075] In this embodiment, the server ensures that the urgent and important second Internet of Things message can be processed in time by setting a message push mechanism of two message channels, which can further improve the reliability of Internet of Things message processing.
[0076] In some embodiments, a large number of IoT messages inevitably contain sensitive information, such as personal identity, location information, etc. If this information cannot be effectively protected, it will lead to serious privacy leakage and security issues. In order to avoid the leakage of sensitive information in IoT messages and even security issues, before performing more than two stages of preprocessing on IoT messages, it also includes:
[0077] Step D1: The server intercepts the encrypted IoT message uploaded by any hardware device.
[0078] In order to ensure the security of IoT message transmission, the server can assign keys to authorized hardware devices. The hardware devices can encrypt IoT messages using the keys assigned by the server and upload the encrypted IoT messages.
[0079] To prevent potential security threats and data confusion, and thus reduce the risk of information leakage, the server can monitor and intercept all encrypted IoT messages uploaded to it.
[0080] Step D2: The server matches the target key based on the device identification code of the hardware device.
[0081] When the server allocates a key to a hardware device, it can record the device identification code of the hardware device and its corresponding key. In order to verify whether the encrypted IoT message is uploaded by an authorized hardware device, the server can match the target key according to the device identification code of the hardware device.
[0082] Step D3: If the target key is matched, the server decrypts the encrypted IoT message based on the target key to obtain the IoT message.
[0083] Step D4: If the target key is not matched, the server refuses to receive the encrypted IoT message.
[0084] For hardware devices that can match the target key, the server can determine that they are authorized hardware devices, and can directly decrypt the encrypted IoT messages uploaded by them based on the target key to obtain the IoT messages to be processed. On the contrary, for hardware devices that fail to match the target key, the server can determine that they are unauthorized hardware devices. In order to prevent potential security threats and data confusion, the server can reject the encrypted IoT messages.
[0085] Optionally, the transmitted IoT messages can be encrypted using the SSL encryption protocol.
[0086] In this embodiment, the server first intercepts all uploaded encrypted IoT messages, and then searches for a matching target key in the key database based on the device identification code. If a matching target key is found, the message is decrypted using the target key to obtain the actual data; if no matching target key is found, the message is rejected. The server performs these processes to ensure that only authorized and correctly decrypted messages can be received and processed, thereby ensuring data security and reliability.
[0087] In some embodiments, in order to facilitate the maintenance of authorized hardware devices and corresponding keys, when a new hardware device is added, the server can call the creation interface of the hardware device and obtain the device identification code of each hardware, and assign corresponding keys to each hardware device in turn based on the device identification code and encryption protocol, and build a key database to facilitate query and matching.
[0088] In some embodiments, different processing stages of IoT messages will generate different data and processing results. For example, pre-processing cache, intermediate result cache, and final result cache. In order to improve the efficiency of data access, the server can classify and hierarchically store each data according to hardware categories and data features (such as warning, metric type), and transmit and store them through different message channels.
[0089] For example, each processing stage can be allocated a level of storage space, and these storage spaces can be divided into different storage areas, each storage area is used to store a type of data generated in the current processing stage. The number of levels of storage space can be divided according to the number of stages; the number of storage areas can be divided according to the number of types of data in each stage.
[0090] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0091] Corresponding to the method for processing the Internet of Things message of the above embodiment, Figure 4 A structural block diagram of an Internet of Things message processing device 4 provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0092] Reference Figure 4 , the Internet of Things message processing device 4 includes:
[0093] The preprocessing module 41 is used to perform more than two stages of preprocessing on the IoT message before performing the parsing operation on the IoT message, and obtain a preprocessing cache corresponding to each stage; the number of preprocessing stages is determined based on the data type required for the parsing operation; different data types correspond to different stages;
[0094] The parsing module 42 is used to call the pre-processing cache of the corresponding stage based on the data type to perform the parsing operation and obtain the parsing result.
[0095] Optionally, a specified number of threads are created based on a central processor for processing Internet of Things messages; the device 4 may also include:
[0096] An acquisition module, used for acquiring the same number of IoT messages as the number of idle threads before performing preprocessing of the IoT messages for more than two stages;
[0097] An allocation module, used to correspond each IoT message to each idle thread one by one;
[0098] The trigger execution module triggers the execution of the preprocessing module 41 and the parsing module 42 for each idle thread based on the corresponding Internet of Things message.
[0099] Optionally, the processing device 4 may further include:
[0100] The first construction module is used to construct a message queue according to the received IoT messages before performing preprocessing of the IoT messages for more than two stages, when the number of idle threads is 0; the IoT messages in the message queue are arranged based on the priority level corresponding to the data type, and the message type corresponding to the IoT message at the head of the message queue has the highest priority level and the earliest timing;
[0101] The priority processing module is used to give priority to processing the IoT message at the head of the queue through a target thread when the message type of the IoT message at the head of the queue is a specified type. The target thread is any non-idle thread that completes the parsing operation.
[0102] Optionally, the above-mentioned parsing module 42 may include:
[0103] The second construction module is used to construct a common message path and a priority message path before performing more than two stages of preprocessing on the IoT message;
[0104] A first push module is used to push the first Internet of Things message to the idle thread in a time sequence through a common message channel; the message type of the first Internet of Things message is not a specified type;
[0105] The second push module is used to push the second Internet of Things message or the first Internet of Things message to the idle thread in a time sequence through the priority message channel; the message type of the second Internet of Things message is a specified type.
[0106] Optionally, the second push module may include:
[0107] A first push submodule, configured to push the second Internet of Things message to the idle thread in a time sequence through a priority message channel if a second Internet of Things message is detected;
[0108] The second push submodule is used to push the first Internet of Things message to the idle thread in time sequence through the priority message channel if the second Internet of Things message is not detected.
[0109] Optionally, the first push submodule is specifically used for:
[0110] If the residence time of the second Internet of Things message in the priority message channel reaches the preset residence time threshold, the ordinary message channel is restricted from pushing the first Internet of Things message to the idle thread, and the second Internet of Things message data is pushed to the idle thread first.
[0111] Optionally, the processing device 4 may further include:
[0112] An interception module is used to intercept encrypted IoT messages uploaded by any hardware device before performing more than two stages of preprocessing on the IoT messages;
[0113] A matching module, for matching a target key based on a device identification code of a hardware device;
[0114] A decryption module is used to decrypt the encrypted IoT message based on the target key to obtain the IoT message if the target key is matched;
[0115] The rejection module is used to refuse to receive the encrypted IoT message if the target key is not matched.
[0116] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0117] Figure 5 This is a schematic diagram of the physical structure of a server provided in an embodiment of the present application. Figure 5 As shown, the server 5 of this embodiment includes: at least one processor 50 ( Figure 5 Only one processor is shown in the figure), a memory 51, and a computer program 52 stored in the memory 51 and executable on at least one processor 50. When the processor 50 executes the computer program 52, the steps in the above-mentioned method for processing any IoT message are implemented, for example Figure 1 Steps 110-120 are shown.
[0118] The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0119] In some embodiments, the memory 51 may be an internal storage unit of the server 5, such as a hard disk or memory of the server 5. In other embodiments, the memory 51 may also be an external storage device of the server 5, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the server 5.
[0120] Furthermore, the memory 51 may include both an internal storage unit of the server 5 and an external storage device. The memory 51 is used to store operating devices, applications, boot loaders, data, and other programs, such as program codes of computer programs, etc. The memory 51 may also be used to temporarily store data that has been output or is to be output.
[0121] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0122] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0123] An embodiment of the present application provides a computer program product. When the computer program product runs on a server, the server can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0124] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The above-mentioned computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the above-mentioned computer program includes computer program code, and the above-mentioned computer program code can be in source code form, object code form, executable file or some intermediate form. The above-mentioned computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera device / server, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electrical carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk.
[0125] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0126] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0127] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the above modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0128] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0129] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A method for processing Internet of Things messages, It is characterized in that include: Before performing a parsing operation on the IoT message, preprocessing the IoT message in more than two stages to obtain a preprocessing cache corresponding to each stage; The number of stages of the preprocessing is determined based on the data type required for the parsing operation; different data types correspond to different stages; Based on the data type, the preprocessing cache of the corresponding stage is called to perform the parsing operation to obtain a parsing result; Wherein, a specified number of threads are created based on a central processor for processing the Internet of Things message; before the Internet of Things message is preprocessed in more than two stages, it also includes: Acquire the same number of IoT messages as the number of idle threads; Each of the Internet of Things messages corresponds to each of the idle threads one by one; For each of the idle threads, based on the corresponding Internet of Things message, the step of performing preprocessing of the Internet of Things message in more than two stages and subsequent steps thereof are returned until a parsing result of the corresponding Internet of Things message is obtained; Before the Internet of Things message is preprocessed in more than two stages, the method further includes: Constructing common message channels and priority message channels; Pushing the first Internet of Things message to the idle thread in time sequence through the common message path; the message type of the first Internet of Things message is not a specified type; Pushing the second Internet of Things message or the first Internet of Things message to the idle thread in time sequence through the priority message path; the message type of the second Internet of Things message is the specified type; The pushing the second Internet of Things message or the first Internet of Things message to the idle thread in time sequence through the priority message path includes: If the second IoT message is detected, pushing the second IoT message to the idle thread in time sequence through the priority message path; If the second IoT message is not detected, pushing the first IoT message to the idle thread in time sequence through the priority message path; The step of pushing the second Internet of Things message to the idle thread in a time sequence through the priority message path includes: If the residence time of the second Internet of Things message in the priority message channel reaches a preset residence time threshold, the ordinary message channel is restricted from pushing the first Internet of Things message to the idle thread, and the second Internet of Things message data is preferentially pushed to the idle thread.
2. The method for processing Internet of Things messages according to claim 1, It is characterized in that Before the Internet of Things message is preprocessed in more than two stages, the method further includes: When the number of idle threads is 0, a message queue is constructed according to the received Internet of Things message; each of the Internet of Things messages in the message queue is arranged based on the priority level corresponding to the data type, and the message type corresponding to the Internet of Things message at the head of the message queue has the highest priority level and the earliest timing; When the message type of the Internet of Things message at the head of the queue is a specified type, the Internet of Things message at the head of the queue is preferentially processed by a target thread, and the target thread is any non-idle thread that completes the parsing operation.
3. The method for processing Internet of Things messages according to claim 1 or 2, It is characterized in that Before the Internet of Things message is preprocessed in more than two stages, the method further includes: Intercept encrypted IoT messages uploaded by any hardware device; matching a target key based on a device identification code of the hardware device; If the target key is matched, decrypting the encrypted IoT message based on the target key to obtain the IoT message; If the target key is not matched, the encrypted IoT message is rejected.
4. A device for processing Internet of Things messages, It is characterized in that include: A preprocessing module, used to perform preprocessing of the IoT message in more than two stages before performing a parsing operation on the IoT message, and obtain a preprocessing cache corresponding to each stage; The number of stages of the preprocessing is determined based on the data type required for the parsing operation; different data types correspond to different stages; A parsing module, configured to call the preprocessing cache of the corresponding stage based on the data type to perform the parsing operation and obtain a parsing result; Wherein, a specified number of threads are created based on a central processor for processing Internet of Things messages; the processing device also includes: An acquisition module, used to acquire the same number of IoT messages as the number of idle threads; An allocation module, used for respectively corresponding each of the Internet of Things messages to each of the idle threads one by one; A triggering execution module, used for triggering the execution of the preprocessing module and the parsing module based on the corresponding Internet of Things message for each of the idle threads; The processing device further comprises: A second construction module is used to construct a common message path and a priority message path before performing more than two stages of preprocessing on the IoT message; A first push module is used to push a first Internet of Things message to an idle thread in a time sequence through the common message path; the message type of the first Internet of Things message is not a specified type; A second push module pushes the second Internet of Things message or the first Internet of Things message to the idle thread in time sequence through the priority message path; the message type of the second Internet of Things message is the specified type; The second push module includes: A first push submodule, configured to push the second Internet of Things message to the idle thread in a time sequence through the priority message path if the second Internet of Things message is detected; A second push submodule, configured to push the first Internet of Things message to the idle thread in a time sequence through the priority message path if the second Internet of Things message is not detected; The second push submodule is specifically used for: If the residence time of the second Internet of Things message in the priority message channel reaches a preset residence time threshold, the ordinary message channel is restricted from pushing the first Internet of Things message to the idle thread, and the second Internet of Things message data is preferentially pushed to the idle thread.
5. A server comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the method for processing the Internet of Things message as described in any one of claims 1 to 3 is implemented.
6. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, the method for processing an Internet of Things message as described in any one of claims 1 to 3 is implemented.
