A message processing method and apparatus
By parsing the device IP and serial number, determining the consistency of associated records, and processing messages asynchronously, the problems of device online message conflicts and duplicate processing are resolved, thereby improving the controller's message processing efficiency and device online success rate.
Patent Information
- Application Number
- CN202310415917.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-14
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2043-04-14
AI Technical Summary
In the controller, when the rate of message production is much greater than the rate of message consumption, messages in the message queue cannot be consumed in a timely manner, causing devices to fail to come online normally. Furthermore, repeated disconnections and reconnections of WebSocket connections due to device IP conflicts consume thread resources and affect message processing efficiency.
By parsing the target device's IP and serial number, it is determined whether there is an associated record. If there is an inconsistency or the number of processing attempts is too high, the message is discarded. An asynchronous processing mechanism is adopted, which divides the message processing process into two stages: obtaining basic device information and issuing configuration. Thread pools are used to manage thread resources.
It improves message processing efficiency, avoids conflicts and duplicate processing of device online messages, reduces thread usage, and enhances the controller's self-protection capabilities and device online success rate.
Smart Images

Figure CN116506388B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of network communication, and in particular to a message processing method and device. BACKGROUND
[0002] The park controller supports device automatic configuration, and a user can realize device automatic online through a small amount of configuration. In the latest automatic configuration scheme of the controller, a WebSocket connection is established between a device and a Websocket component of an operation and maintenance platform to realize interaction, and the Websocket of the platform sends a message to the controller when establishing the connection.
[0003] The message of the device establishing the connection is first put into a message queue in the controller, and a specific process consumes the message. At this time, a problem is generated: when the speed of producing the message is much greater than the speed of consumption, the message in the message queue cannot be consumed in time, and the subsequent message is blocked in the queue. The newly accessed device cannot be normally online on the controller.
[0004] At present, when an exception occurs in the environment, common exception conditions are address conflicts caused by the same IP of the device (for example, brain split of stacked devices), and the WebSocket connection established by the device is repeatedly disconnected and reconnected. A specific example is that the IP of device A is the same as that of device B, so that the two devices can simultaneously establish a WebSocket connection. However, the TCP connection of the same IP can only maintain one, and when the A device establishes the connection, the B device is disconnected; when the B device establishes the connection, the A device is disconnected. The WebSocket component notifies the controller of all the messages, and the messages in different conditions only contain the IP, sequence number and other basic information of the device, and cannot distinguish the message in which condition the message is sent. The controller is the last end of the message transmission and cannot interfere with the processing flow of the WebSocket. The controller can only passively accept and process all the messages, and a large amount of messages leads to the occupation of threads, so that the new device cannot be online.
[0005] Therefore, how the controller improves the message processing efficiency becomes a problem to be solved at present. SUMMARY
[0006] The present application provides a message processing method and device.
[0007] In a first aspect, the present application provides a message processing method applied to a controller, and the method comprises the following steps.
[0008] Analyzing an online message of a target device to obtain a target IP of the target device and a target device sequence number;
[0009] determining whether the local device maintains an association record of the IP and the device serial number matching the target IP;
[0010] If it is determined that the local device maintains an association record of the IP and the device serial number matching the target IP, it is determined whether the target device serial number is consistent with the device serial number included in the association record.
[0011] If it is determined that the target device serial number is not consistent with the device serial number included in the association record, the online message of the target device is discarded.
[0012] Optionally, the method further comprises:
[0013] If it is determined that the local device does not maintain an association record of the IP and the device serial number matching the target IP, an association record of the target IP and the target device serial number is recorded locally, and the device count corresponding to the target IP is incremented by 1.
[0014] Optionally, the method further comprises:
[0015] If it is determined that the target device serial number is consistent with the device serial number included in the association record, it is determined whether the number of online message processing corresponding to the IP is greater than a set threshold value, if yes, the online message of the target device is discarded; otherwise, the online message of the target device is processed, and the number of online message processing corresponding to the target IP is incremented by 1.
[0016] Optionally, when parsing an online message corresponding to an IP, a timestamp of parsing the online message is recorded; the method further comprises:
[0017] Based on a preset period, it is determined whether the device count corresponding to each IP is 1, if the device count corresponding to an IP is 1, and the difference between the timestamp of the last time of parsing the online message corresponding to the device and the current time is greater than a preset threshold value, the association record and the count information corresponding to the IP are deleted.
[0018] If the device count corresponding to an IP is greater than 1, it is determined whether the difference between the timestamp of the last time of parsing the online message corresponding to each device and the current time is greater than a preset threshold value, if the number of devices whose difference is less than the set threshold value is less than or equal to 1, the association record and the count information corresponding to the IP are deleted.
[0019] Optionally, the processing process of the online message is divided into a first stage of obtaining device basic information and a second stage of issuing configuration to the device; the step of processing the online message of the target device comprises:
[0020] A first thread is started to obtain the device basic information of the target device, and after determining that the execution is completed, the first thread is released.
[0021] starting a second thread, judging whether a second-stage executed record of the target device exists locally, if yes, discarding the online message of the target device and releasing the second thread; otherwise, interacting with the target device, performing a configuration delivery operation, and releasing the second thread after determining that the operation is completed, and recording the second-stage executed record of the target device.
[0022] In a second aspect, the present application provides a message processing device applied to a controller, the device comprising:
[0023] a parsing unit configured to parse an online message of a target device to obtain a target IP and a target device serial number of the target device;
[0024] a judging unit configured to judge whether an associated record of an IP and a device serial number matched with the target IP is maintained locally;
[0025] if the judging unit determines that the associated record of the IP and the device serial number matched with the target IP is maintained locally, the judging unit is further configured to judge whether the target device serial number is consistent with a device serial number included in the associated record;
[0026] a processing unit, if the judging unit determines that the target device serial number is not consistent with the device serial number included in the associated record, the processing unit is configured to discard the online message of the target device.
[0027] Optionally, the device further comprises:
[0028] a recording unit, if the judging unit determines that the associated record of the IP and the device serial number matched with the target IP is not maintained locally, the recording unit is configured to record the associated record of the target IP and the target device serial number locally, and increase a device count corresponding to the target IP by 1.
[0029] Optionally, if the judging unit determines that the target device serial number is not consistent with the device serial number included in the associated record, the judging unit is further configured to judge whether a processing number of the online message corresponding to the IP is greater than a set threshold, if yes, the processing unit is configured to discard the online message of the target device; otherwise, the processing unit is configured to process the online message of the target device, and increase the processing number of the online message corresponding to the target IP by 1.
[0030] Optionally, when parsing an online message corresponding to an IP, a time stamp of parsing the online message is recorded; the device further comprises:
[0031] The deleting unit is configured to determine whether the device count corresponding to each IP is 1 based on a preset period, and if the device count corresponding to one IP is 1 and the difference between the timestamp of the last time the online message is parsed by the device corresponding to the IP and the current time is greater than a preset threshold, delete the association record and the count information corresponding to the IP.
[0032] If the device count corresponding to one IP is greater than 1, determine whether the difference between the timestamp of the last time the online message is parsed by each device and the current time is greater than a preset threshold, and if the number of devices whose difference is less than the set threshold is less than or equal to 1, the deleting unit is configured to delete the association record and the count information corresponding to the IP.
[0033] Optionally, the processing process of the online message is divided into a first stage of obtaining device basic information and a second stage of issuing configuration to the device; when processing the online message of the target device, the processing unit is specifically configured to:
[0034] start a first thread to obtain the device basic information of the target device, and release the first thread after determining that the execution is completed;
[0035] start a second thread to determine whether there is a record of the second stage of the target device that has been executed locally, if there is, discard the online message of the target device and release the second thread; otherwise, interact with the target device, execute the configuration issuing operation, and release the second thread after determining that the execution is completed, and record the record of the second stage of the target device that has been executed.
[0036] In a third aspect, an embodiment of the present application provides a message processing device, which comprises:
[0037] a memory configured to store program instructions;
[0038] a processor configured to invoke the program instructions stored in the memory, and execute the steps of the method according to any one of the above first aspect.
[0039] In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium, which stores computer executable instructions, and the computer executable instructions are used to make the computer execute the steps of the method according to any one of the above first aspect.
[0040] In summary, the message processing method provided in the embodiments of the present application analyzes the online message of the target device to obtain the target IP and the target device serial number of the target device; determines whether the local maintains an associated record of the IP and the device serial number matched with the target IP; if it is determined that the local maintains the associated record of the IP and the device serial number matched with the target IP, determines whether the target device serial number is consistent with the device serial number included in the associated record; and if it is determined that the target device serial number is not consistent with the device serial number included in the associated record, discards the online message of the target device.
[0041] By using the message processing method provided in the embodiments of the present application, the controller is the last end of message processing, and the address conflict between devices in the online message is detected to achieve the ability of self-protection of discarding the conflict message, improving the processing efficiency, and timely sending an alarm to let the user know and process. BRIEF DESCRIPTION OF DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the description of the embodiments of the present application or the prior art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments described in the present application, and other drawings can also be obtained by those skilled in the art according to these drawings of the embodiments of the present application.
[0043] Figure 1 A detailed flowchart of a message processing method provided in the embodiments of the present application;
[0044] Figure 2 A structural schematic diagram of a message processing device provided in the embodiments of the present application;
[0045] Figure 3 A hardware architecture schematic diagram of a message processing device provided in the embodiments of the present application. DETAILED DESCRIPTION
[0046] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "an" and "the" used in the present application and claims are intended to include plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein means any or all possible combinations of one or more associated listed items.
[0047] It should be understood that, although the embodiments herein can employ the terms first, second, third, etc. to describe various information, the information should not be limited to these terms. These terms are only used to distinguish one piece of information from another piece of information of the same type. For example, without departing from the scope of the present application, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information. Depending on the context, in addition, the word "if" used can be interpreted as "when" or "upon" or "in response to determining".
[0048] For example, refer to Figure 1 As shown in the detailed flowchart of a message processing method provided by the embodiments of the present application, the method is applied to a controller, and the method comprises the following steps:
[0049] Step 100: parsing the online message of a target device to obtain the target IP and the target device serial number of the target device.
[0050] In actual application, after the device to be online establishes a websocket connection with the websocket component of the operation and maintenance platform, the websocket component sends the message (online message) of establishing the connection with the device to the controller through the message middleware. Specifically, the controller can put the received online message into the message queue, and then a specific process consumes the message in the message queue.
[0051] Then, when the controller consumes the message in the message queue, the online message of the target device to be processed is obtained from the message queue, and then the online message of the target device is parsed to obtain the IP address and the device serial number of the target device.
[0052] Step 110: judging whether the local maintains an associated record of the IP and the device serial number matched with the target IP.
[0053] In the embodiments of the present application, if it is determined that the local does not maintain an associated record of the IP and the device serial number matched with the target IP, an associated record of the target IP and the target device serial number is recorded locally, and the device count corresponding to the target IP is increased by 1.
[0054] The device count corresponding to an IP refers to the number of devices using the IP to send online messages.
[0055] Specifically, the associated relationship of each device that has sent an online message and the IP address used by the device is added. When an IP address is used by a device for the first time, the device is connected with the websocket component for device online, and the controller parses the online message to maintain the associated relationship of the IP address and the device serial number of the device in the local.
[0056] In this way, when processing a subsequent online message, the controller first determines whether the IP carried by the online message is recorded locally. If not, the controller directly processes the online message and records / maintains the association between the IP and the device serial number of the corresponding device locally.
[0057] Step 120: If it is determined that the local maintenance has the association record of the IP and the device serial number matching the target IP, it is determined whether the target device serial number is consistent with the device serial number included in the association record.
[0058] Specifically, if the controller determines that the local maintenance has the association between the IP address corresponding to the target IP and the device serial number, it means that the device has sent an online message using the target IP. Therefore, it is further determined whether the target device serial number of the target device is consistent with the device serial number included in the association record.
[0059] Step 130: If it is determined that the target device serial number is not consistent with the device serial number included in the association record, the online message of the target device is discarded.
[0060] That is, if the controller determines that the target device serial number is not consistent with the device serial number included in the association record, it means that there may be an IP address conflict, i.e., different devices use the same IP address for online operation. Since the target IP address has been used for online operation by other devices, the online message is directly discarded and not processed. Further, the controller increments the device count corresponding to the target IP by 1. Obviously, the device count corresponding to the target IP is greater than or equal to 2 at this time.
[0061] In the embodiment of the application, if it is determined that the target device serial number is consistent with the device serial number included in the association record, it is determined whether the online message processing number corresponding to the IP is greater than a set threshold. If yes, the online message of the target device is discarded. Otherwise, the online message of the target device is processed and the online message processing number corresponding to the target IP is incremented by 1.
[0062] That is, the target device sends an online message to the controller using the target IP multiple times, and the controller has processed the online message sent by the target device. The controller records the online message processing number corresponding to the target IP and the target device to be incremented by 1 each time the target device uses the target IP to send an online message. Of course, in the embodiment of the application, when processing the first online message of the target device using the target IP, the online message processing number corresponding to the target IP can not be incremented, or the online message processing number corresponding to the target IP can be incremented. In this embodiment, it is not specifically limited.
[0063] In this way, whether a device (network concussion) repeatedly sends a large number of online messages is detected, if yes, only a specified number of online messages are processed, and subsequent online messages are not processed, so as to avoid that the device frequently sends online messages and occupies controller resources.
[0064] Further, in the embodiment of the application, when an online message is parsed, the timestamp information of parsing the online message can be recorded, for example, {target IP, target device serial number, timestamp} is recorded locally, of course, only the timestamp of the last time of parsing the online message corresponding to the target IP and the target device serial number can be recorded, for example, it is assumed that {target IP, target device serial number, timestamp 1} has been recorded for the target IP and the target device serial number, if an online message with the target IP and the target device serial number is parsed again, {target IP, target device serial number, timestamp 1} is replaced with {target IP, target device serial number, timestamp 2}.
[0065] Then, the message processing method described above can further include the following steps in the embodiment of the application:
[0066] Based on the preset period, whether the device count corresponding to each IP is 1 is determined, if the device count corresponding to an IP is 1, and the difference between the timestamp of the last time of parsing the online message of the device and the current time is greater than a preset threshold, the association record and the count information corresponding to the IP are deleted;
[0067] If the device count corresponding to an IP is greater than 1, whether the difference between the timestamp of the last time of parsing the online message of each device and the current time is greater than a preset threshold is determined, if the number of devices whose difference is less than the set threshold is less than or equal to 1, the association record and the count information corresponding to the IP are deleted.
[0068] For example, the preset period is 3 minutes / 5 minutes (for example, 3 minutes, which can be customized based on user demand / application scenario), then, the traversal can be performed every 3 minutes, whether the device count corresponding to each IP is 1 is determined, if the device count corresponding to an IP is 1, it is determined that only one device of the IP is used to log in, and whether the difference between the timestamp of the last time of parsing the online message of the IP and the device and the current time is greater than 5 minutes is further determined, if yes, it is indicated that the device using the IP has not sent an online message in the past 3 minutes, the association relationship between the IP address and the device serial number of the device and the count information (the count of parsing the online message, the device count of the IP) of the device corresponding to the IP can be deleted, in this way, if the device is replaced by other devices due to failure, and the IP is still used to log in normally.
[0069] If the device count corresponding to an IP address is not 1, it indicates that multiple devices (e.g., device 1 and device 2) have used that IP address to go online. In this case, it's necessary to determine if the difference between the timestamp of the last online message parsed for each device using that IP address and the current time is greater than 5 minutes. If the difference is greater than 5 minutes for both device 1 and device 2, the association and count information corresponding to that IP address can be deleted. If the difference is less than 5 minutes for only one device, the association and count information corresponding to that IP address can also be deleted. If the difference is less than 5 minutes for both devices, it means that the two devices may still be competing for the WebSocket connection and will still send online messages to the controller; in this case, the association and count information corresponding to that IP address will not be deleted for the time being.
[0070] In this embodiment, the online message is processed in segments using asynchronous processing.
[0071] Specifically, the online message processing process is divided into a first stage of obtaining basic device information and a second stage of sending configuration to the device; the steps for processing the online message of the target device include:
[0072] Start the first thread to obtain the basic device information of the target device, and release the first thread after the execution is completed.
[0073] Start a second thread to determine if there is a record of the second phase of the target device being executed locally. If there is, discard the online message of the target device and release the second thread; otherwise, interact with the target device, execute the configuration distribution operation, and release the second thread after confirming that the execution is complete, and record the record of the second phase of the target device being executed.
[0074] This is to avoid repeatedly sending configurations to the same device, which would consume threads and improve message processing efficiency.
[0075] Furthermore, in this embodiment, a corresponding thread lock is configured for each device. When a thread is already processing an online message for a device, it occupies the thread lock of that device so that other threads cannot process other online messages for that device, thereby avoiding the situation where several devices send a large number of duplicate online messages and occupy all threads.
[0076] For example, see Figure 2 The diagram shown is a structural schematic of a message processing device provided in an embodiment of this application. This device is applied to a controller and includes:
[0077] Parsing unit 20 is used to parse the online message of the target device to obtain the target IP and target device serial number of the target device;
[0078] The judging unit 21 is configured to judge whether the local maintains an association record of the IP and the device serial number matched with the target IP.
[0079] If the judging unit 21 judges that the local maintains the association record of the IP and the device serial number matched with the target IP, the judging unit 21 is further configured to judge whether the target device serial number is consistent with the device serial number included in the association record.
[0080] The processing unit 22 is configured to discard the online message of the target device if the judging unit 21 judges that the target device serial number is not consistent with the device serial number included in the association record.
[0081] Optionally, the device further comprises:
[0082] The recording unit is configured to record the association record of the target IP and the target device serial number in the local and add 1 to the device count corresponding to the target IP if the judging unit 21 judges that the local does not maintain the association record of the IP and the device serial number matched with the target IP.
[0083] Optionally, if the judging unit 21 judges that the target device serial number is not consistent with the device serial number included in the association record, the judging unit 21 is further configured to judge whether the processing times of the online message corresponding to the IP is greater than a set threshold value, and if yes, the processing unit 22 is configured to discard the online message of the target device; otherwise, the processing unit 22 is configured to process the online message of the target device and add 1 to the processing times of the online message corresponding to the target IP.
[0084] Optionally, when the online message corresponding to one IP is parsed, the time stamp of parsing the online message is recorded; the device further comprises:
[0085] The deleting unit is configured to judge whether the device count corresponding to each IP is 1 based on a preset period, and if the device count corresponding to one IP is 1 and the difference between the time stamp of the last time of parsing the online message corresponding to the device and the current time is greater than a preset threshold value, the deleting unit is configured to delete the association record and the count information corresponding to the IP.
[0086] If the device count corresponding to one IP is greater than 1, the deleting unit is configured to judge whether the difference between the time stamp of the last time of parsing the online message corresponding to each device and the current time is greater than a preset threshold value, and if the number of devices whose difference is less than the set threshold value is less than or equal to 1, the deleting unit is configured to delete the association record and the count information corresponding to the IP.
[0087] Optionally, the process of the online message is divided into a first stage of obtaining device basic information and a second stage of issuing configuration to the device; when processing the online message of the target device, the processing unit 22 is specifically configured to:
[0088] starting a first thread, obtaining the device basic information of the target device, and releasing the first thread after determining that the execution is completed;
[0089] starting a second thread, judging whether the second stage of the target device has been executed locally, if yes, discarding the online message of the target device and releasing the second thread; otherwise, interacting with the target device, executing the operation of configuration issuing, and releasing the second thread after determining that the execution is completed, and recording the second stage of the target device has been executed.
[0090] The above units can be one or more integrated circuits configured to implement the above methods, for example: one or more application specific integrated circuits (ASICs), or one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs), etc. For another example, when the above certain unit is implemented in the form of a processing element scheduling code, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these units can be integrated together in the form of a system on a chip (SOC).
[0091] Further, the message processing apparatus provided by the embodiments of the present application is from the hardware layer, and a hardware architecture diagram of the message processing apparatus can be seen from Figure 3 As shown in the figure, the message processing apparatus can include a memory 30 and a processor 31,
[0092] The memory 30 is used to store program instructions; the processor 31 calls the program instructions stored in the memory 30, and executes the above method embodiments according to the obtained program instructions. The specific implementation and technical effects are similar, and will not be repeated here.
[0093] Optionally, the present application also provides a controller comprising at least one processing element (or chip) for executing the above method embodiments.
[0094] Optionally, the present application also provides a program product, for example, a computer readable storage medium, which stores computer executable instructions for causing the computer to execute the above method embodiments.
[0095] Here, the machine readable storage medium can be any electronic, magnetic, optical, or other physical storage device that contains or stores information, such as executable instructions, data, etc. For example, the machine readable storage medium can be a RAM (Random Access Memory), a volatile memory, a non-volatile memory, a flash memory, a storage drive (such as a hard drive), a solid state drive, any type of storage disk (such as a floppy disk, a DVD, etc.), or similar storage medium, or a combination thereof.
[0096] The systems, apparatuses, modules or units illustrated by the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an e-mail device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0097] For the convenience of description, the above apparatuses are described in various units by functions respectively when described. Of course, the functions of the units can be implemented in one or more software and / or hardware in the implementation of the present application.
[0098] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, a disk storage, a CD-ROM, an optical storage, etc.) containing computer-usable program code.
[0099] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce the functions described in the flowcharts and / or block diagrams for implementing the flows and / or blocks in the flowcharts and / or block diagrams. Figure 1apparatuses that implement the functions specified in the flowchart or flowcharts and / or blocks. Figure 1
[0100] Also, these computer program instructions can be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the flowchart or flowcharts and / or blocks. Figure 1 apparatuses that implement the functions specified in the flowchart or flowcharts and / or blocks. Figure 1
[0101] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flowchart or flowcharts and / or blocks. Figure 1 apparatuses that implement the functions specified in the flowchart or flowcharts and / or blocks. Figure 1
[0102] The above description is embodied in the context of only a few of the preferred embodiments and are not intended to be exclusive or limiting of this application. Any modification, equivalent substitution, improvement, and the like that are made within the spirit and principle of this application should be included in the scope of protection of this application.
Claims
1. A message processing method, characterized in that, Applied to a controller, the method includes: Parse the online message of the target device to obtain the target IP and target device serial number; Determine whether a record of the associated IP and device serial number matching the target IP is maintained locally; If it is determined that there is an association record of IP and device serial number that matches the target IP in the local maintenance, then it is determined whether the target device serial number is consistent with the device serial number included in the association record; If it is determined that the target device serial number is inconsistent with the device serial number included in the associated record, then the online message of the target device is discarded.
2. The method as described in claim 1, characterized in that, The method further includes: If it is determined that there is no associated record of IP and device serial number matching the target IP maintained locally, then the associated record of the target IP and target device serial number is recorded locally, and the device count corresponding to the target IP is incremented by 1.
3. The method as described in claim 2, characterized in that, The method further includes: If the target device serial number is determined to be consistent with the device serial number included in the associated record, then it is determined whether the number of online message processing times corresponding to the IP is greater than a set threshold. If so, the online message of the target device is discarded; otherwise, the online message of the target device is processed, and the number of online message processing times corresponding to the target IP is incremented by 1.
4. The method according to any one of claims 1-3, characterized in that, When parsing an online message corresponding to an IP address, the timestamp of parsing the online message is recorded; the method further includes: Based on a preset period, it is determined whether the device count corresponding to each IP is 1. If the device count corresponding to an IP is 1, and the difference between the timestamp of the last online message parsed by the device and the current time is greater than a preset threshold, then the associated record and count information corresponding to the IP are deleted. If the device count corresponding to an IP is greater than 1, then determine whether the difference between the timestamp of the last parsed online message for each device and the current time is greater than a preset threshold. If the number of devices with a difference less than the set threshold is less than or equal to 1, then delete the associated record and count information corresponding to that IP.
5. The method as described in claim 1, characterized in that, The process of processing the online message is divided into the first stage of obtaining basic device information and the second stage of sending configuration to the device. The steps for processing the online message of the target device include: Start the first thread to obtain the basic device information of the target device, and release the first thread after the execution is completed; Start a second thread to determine if there is a record of the second phase of the target device being executed locally. If there is, discard the online message of the target device and release the second thread; otherwise, interact with the target device, execute the configuration distribution operation, and release the second thread after confirming that the execution is complete, and record the record of the second phase of the target device being executed.
6. A message processing device, characterized in that, Applied to a controller, the device includes: The parsing unit is used to parse the online message of the target device to obtain the target IP and the target device serial number. The judgment unit is used to determine whether there is an association record of IP and device serial number that matches the target IP maintained locally; If the determination unit determines that there is an association record of IP and device serial number that matches the target IP in the local maintenance, the determination unit is further used to determine whether the target device serial number is consistent with the device serial number included in the association record; If the judgment unit determines that the target device serial number is inconsistent with the device serial number included in the associated record, the processing unit is used to discard the online message of the target device.
7. The apparatus as claimed in claim 6, characterized in that, The device further includes: If the judgment unit determines that there is no associated record of IP and device serial number matching the target IP maintained locally, the recording unit is used to record the associated record of the target IP and target device serial number locally and increment the device count corresponding to the target IP by 1.
8. The apparatus as claimed in claim 7, characterized in that, If the judgment unit determines that the target device serial number is inconsistent with the device serial number included in the associated record, the judgment unit is further configured to determine whether the number of online message processing times corresponding to the IP is greater than a set threshold. If so, the processing unit is configured to discard the online message of the target device; otherwise, the processing unit is configured to process the online message of the target device and increment the number of online message processing times corresponding to the target IP by 1.
9. A message processing device, characterized in that, The message processing device includes: Memory, used to store program instructions; A processor is configured to invoke program instructions stored in the memory and execute the steps of the method as described in any one of claims 1-5 according to the obtained program instructions.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing the computer to perform the steps of the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Message processing method, device and equipment and storage medium
CN112260965A
Internet-of-Things equipment processing method, device and equipment
CN112398964A