CN115065736A - Message processing method and device, electronic equipment and storage medium - Google Patents
Message processing method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN115065736A CN115065736A CN202210329656.2A CN202210329656A CN115065736A CN 115065736 A CN115065736 A CN 115065736A CN 202210329656 A CN202210329656 A CN 202210329656A CN 115065736 A CN115065736 A CN 115065736A
- Authority
- CN
- China
- Prior art keywords
- instruction
- processed
- message
- rule
- rule file
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 18
- 238000004458 analytical method Methods 0.000 claims abstract description 91
- 238000000034 method Methods 0.000 claims abstract description 43
- 238000004891 communication Methods 0.000 claims description 19
- 230000002159 abnormal effect Effects 0.000 claims description 7
- 238000004590 computer program Methods 0.000 claims description 6
- 230000008569 process Effects 0.000 description 16
- 238000010586 diagram Methods 0.000 description 11
- 230000009471 action Effects 0.000 description 3
- 230000006870 function Effects 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- RWSOTUBLDIXVET-UHFFFAOYSA-N Dihydrogen sulfide Chemical compound S RWSOTUBLDIXVET-UHFFFAOYSA-N 0.000 description 1
- 230000005856 abnormality Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000009191 jumping Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/22—Parsing or analysis of headers
-
- G—PHYSICS
- G16—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
- G16Y—INFORMATION AND COMMUNICATION TECHNOLOGY SPECIALLY ADAPTED FOR THE INTERNET OF THINGS [IoT]
- G16Y10/00—Economic sectors
- G16Y10/75—Information technology; Communication
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/06—Management of faults, events, alarms or notifications
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Development Economics (AREA)
- Economics (AREA)
- General Business, Economics & Management (AREA)
- Computing Systems (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The embodiment of the application relates to a message processing method, a message processing device, electronic equipment and a storage medium, wherein the message processing method comprises the following steps: the method comprises the steps of obtaining a command to be processed, analyzing a message carried in the command to be processed by using an original analysis rule, obtaining a pre-compiled rule file if the analysis fails, matching the command to be processed with a predefined command in the rule file, obtaining a command type of the predefined command in the rule file if the matching succeeds, and processing the message carried in the command to be processed according to the command type. Therefore, when the extended service is realized, the pre-written rule file is used for matching, the existing code does not need to be modified, and the influence on the existing service is reduced.
Description
Technical Field
The embodiment of the application relates to the technical field of intelligent internet of things platforms, in particular to a message processing method and device, electronic equipment and a storage medium.
Background
At present, people can not leave the intelligent internet of things platform in all aspects of life, and the intelligent internet of things platform is applied to various industries. The intelligent Internet of things platform is widely applied, on one hand, the life of people is facilitated, and people can transact business through different intelligent Internet of things platforms without going out of home; on the other hand, the management of a certain type of service is facilitated. For example, people can pay for life through the intelligent Internet of things platform, and meanwhile, many workers are not needed to charge offline; the student can carry out course study through intelligence thing allies oneself with the platform, and the school also can manage the student through intelligence thing allies oneself with the platform simultaneously and so on.
With the continuous expansion of the use scenes of the intelligent internet of things platform, the number of devices required to be accessed by the intelligent internet of things platform is gradually increased, and the number of services required to be processed is also increased. At present, an online intelligent internet of things platform access protocol cannot meet a continuously expanded service scene, so that an existing online hardware interaction protocol needs to be continuously perfected to adapt to a new service scene.
In the prior art, upgrading and reconstruction of the online protocol are difficult, the existing protocol code needs to be modified, upgrading is redeployed, and the existing service is influenced more or less in the upgrading process. Therefore, a method for modifying online codes at a time is needed to reduce the influence on the existing services.
Disclosure of Invention
In view of this, in order to solve the technical problems that upgrading and reconstruction of an online protocol are difficult, an existing protocol code needs to be modified, upgrading needs to be redeployed, and existing services are more or less affected in an upgrading process, embodiments of the present application provide a message processing method and apparatus, an electronic device, and a storage medium.
In a first aspect, an embodiment of the present application provides a message processing method, which is applied to an intelligent internet of things platform, and the method includes:
acquiring a command to be processed;
analyzing the message carried in the instruction to be processed by using the original analysis rule;
if the analysis fails, acquiring a pre-compiled rule file;
matching the instruction to be processed with a predefined instruction in the rule file;
if the matching is successful, acquiring the instruction type of the predefined instruction in the rule file;
and processing the message carried in the instruction to be processed according to the instruction type.
In an optional embodiment, the obtaining the instruction to be processed includes:
receiving an instruction reported to the platform by the equipment;
or the like, or, alternatively,
and acquiring an instruction issued by the platform to the equipment.
In an optional embodiment, the obtaining a pre-written rule file includes:
and acquiring a pre-written rule file in a hot deployment and loading mode.
In an optional embodiment, the processing, according to the instruction type, a packet carried in the instruction to be processed includes:
analyzing the message carried in the instruction to be processed according to an analysis rule corresponding to the instruction type, and acquiring the analyzed message;
and searching a message forwarding position corresponding to the instruction type, and forwarding the analyzed message according to the message forwarding position.
In an optional embodiment, the parsing, by using the original parsing rule, the packet carried in the instruction to be processed includes:
determining a sender of the instruction to be processed, and judging whether the sender is in a preset white list or not, wherein a plurality of credible senders are recorded in the preset white list;
and if the sender is in the preset white list, analyzing the message carried in the instruction to be processed by using the original analysis rule.
In an optional embodiment, the obtaining a pre-written rule file if the parsing fails includes:
if the analysis fails, determining the reason of the message analysis failure, wherein the reason comprises an equipment reason, a network reason or a reason that an original analysis rule is not matched with the instruction to be processed;
if the reason comprises the reason that the original analysis rule is not matched with the instruction to be processed, acquiring a pre-compiled rule file;
if the reason is not the reason that the original analysis rule is not matched with the instruction to be processed, triggering an alarm; and the number of the first and second groups,
and skipping to the step of analyzing the message carried in the instruction to be processed by using the original analysis rule.
In an optional embodiment, the obtaining a pre-written rule file if the parsing fails includes:
if the analysis is failed, detecting whether the instruction to be processed is normal;
if the instruction to be processed is normal, acquiring a pre-compiled rule file;
and if the instruction to be processed is abnormal, triggering an alarm of the instruction abnormity.
In a second aspect, an embodiment of the present application provides a message processing apparatus, which is applied to an intelligent internet of things platform, and the apparatus includes:
an instruction acquisition module: the method comprises the steps of obtaining an instruction to be processed;
an analysis module: the message analysis module is used for analyzing the message carried in the instruction to be processed by utilizing the original analysis rule;
a rule file acquisition module: the rule file pre-compiling module is used for acquiring a pre-compiled rule file if the analysis fails;
a rule matching module: the instruction matching module is used for matching the instruction to be processed with a predefined instruction in the rule file;
an instruction type acquisition module: the instruction type of the predefined instruction in the rule file is obtained if the matching is successful;
a message processing module: and the message processing module is used for processing the message carried in the instruction to be processed according to the instruction type.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete mutual communication through the communication bus;
a memory for storing a computer program;
a processor adapted to perform the method of any of the first aspect when executing a program stored in the memory.
In a fourth aspect, embodiments of the present application provide a storage medium storing one or more programs, which are executable by one or more processors to implement the method of any one of the first aspects.
According to the technical scheme provided by the embodiment of the application, the instruction to be processed is obtained; analyzing the message carried in the instruction to be processed by using the original analysis rule; if the analysis fails, acquiring a pre-compiled rule file; matching the instruction to be processed with a predefined instruction in the rule file; if the matching is successful, acquiring the instruction type of the predefined instruction in the rule file; and processing the message carried in the instruction to be processed according to the instruction type. By writing the rule file in advance, the message which cannot be analyzed by the original analysis rule is processed without modifying the existing code, so that the influence on the existing service is reduced.
Drawings
Fig. 1 is a schematic diagram illustrating an implementation flow of a message processing method according to an embodiment of the present application;
fig. 2 is a schematic flow chart illustrating an implementation of a message processing method when a device reports an instruction to a platform according to an embodiment of the present application;
fig. 3 is a schematic diagram illustrating an implementation flow of a message processing method when another device reports an instruction to a platform according to an embodiment of the present application;
fig. 4 is a schematic diagram illustrating an implementation flow of another message processing method according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a message processing apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The following further explains the message processing method provided by the present application with a specific embodiment in combination with the accompanying drawings, and the embodiment does not limit the embodiment of the present application.
Fig. 1 is a schematic diagram of an implementation flow of a message processing method provided in an embodiment of the present application, where the method is applied to an intelligent internet of things platform, and the method may include the following steps:
s101: and acquiring the instruction to be processed.
In the embodiment of the application, a plurality of to-be-processed instructions are arranged in the intelligent internet of things platform, and the to-be-processed instructions to be processed at present are obtained according to the urgency degree, the generation time and the like of the to-be-processed instructions. For example, when the intelligent internet of things platform is an intelligent student identity card platform, the instruction to be processed is a sign-in instruction of a student, and the intelligent student identity card platform needs to acquire the instruction according to the sign-in time of the student due to different sign-in times of the student. In addition, the intelligent internet of things platform can also be other intelligent internet of things platforms, and the instructions to be processed are different according to different intelligent internet of things platforms and different services to be processed.
In this embodiment of the present application, the instruction to be processed may be an instruction that is reported by the device to the platform, or an instruction that is issued by the platform to the device, and this application is not limited to this.
S102: and analyzing the message carried in the instruction to be processed by utilizing the original analysis rule.
In this embodiment of the application, the instruction to be processed carries message data, for example, the intelligent internet of things platform of the application is an intelligent student identity card platform, and when the instruction to be processed is a sign-in instruction, the message data carried in the sign-in instruction may include personal information, course information, sign-in time, and the like of a student, which is not limited in this application.
In the embodiment of the application, after the intelligent internet of things platform acquires the instruction to be processed, the original analysis rule is used for analyzing the message data carried in the instruction to be processed, and the original analysis rule is the existing business logic processing rule of the intelligent internet of things platform. For example, the intelligent internet of things platform of this application is intelligent student's card platform, and the instruction of awaiting processing is student's instruction of registering, contains the analytic rule to the message that carries in the instruction of registering in the intelligent student's card platform, can handle student's instruction of registering, and then the analytic rule of the instruction of registering is the original analytic rule of intelligent student's card platform promptly.
It should be noted that the intelligent internet of things platform in the present application may also be other platforms, such as a life payment platform, and the like, the instruction to be processed is different according to the platform and the service to be processed, and different instructions to be processed may also carry different message data, which is not limited in the present application.
S103: and if the analysis fails, acquiring a pre-written rule file.
In the embodiment of the application, the pre-written rule file is an extended rule of the intelligent internet of things platform and is a rule added on the basis of an original analysis rule of the intelligent internet of things platform. If the original parsing rule is used in S102 to parse the message data carried in the instruction to be processed, the original parsing rule cannot be parsed, that is, the original service processing logic of the intelligent internet of things platform does not contain the parsing rule of the message carried in the instruction to be processed, at this time, the intelligent internet of things platform may obtain a pre-compiled rule file to process the instruction to be processed.
For example, when the intelligence thing allies oneself with the platform of this application is intelligence student's card platform, if make intelligence student's card platform not contain the function of registering this moment, the school has held an activity newly, needs the student to register at intelligence student's card platform, and that student's instruction of registering is that can't use intelligence student's card platform to handle, therefore intelligence student's card platform goes to obtain the rule file, handles student's instruction of registering. In addition, the intelligent internet of things platform and the instruction types are not limited in the application.
S104: and matching the instruction to be processed with the instruction predefined in the rule file.
In this embodiment of the application, in S103, a pre-programmed rule file is obtained, where the rule file includes all extension rules for the intelligent internet of things platform, and therefore after the rule file is obtained, a to-be-processed instruction needs to be matched with a predefined instruction in the rule file, and a processing rule for the to-be-processed instruction is obtained from the rule file.
S105: and if the matching is successful, acquiring the instruction type of the predefined instruction in the rule file.
In this embodiment of the application, after the instruction TO be processed is successfully matched with the predefined instruction in the rule file in S104, the predefined instruction type in the rule file is obtained, for example, the instruction TO be processed is matched with the predefined instruction in the rule file, and when the matched predefined instruction name is "SET _ DATA _ TO _ REDIS", the instruction type of the instruction is obtained, and the matching code and the instruction type obtaining statement are as follows:
$p:PacketMsg($p.funId=="SET_DATA_TO_REDIS")。
it should be noted that the names of the instructions included in the rule file of the present application are predefined by a person writing the rule file in the writing process of the rule file, and may also be other values, such as "SET _ DATA _ TO _ MySQL", "SET _ DATA _ TO _ rocktmq", and the present application is not limited in this respect. Matching codes and instruction type obtaining statements are also only given as an example, and whether the instruction is successfully obtained or not and obtaining a predefined instruction type can also be judged through other statements.
S106: and processing the message carried in the instruction to be processed according to the instruction type.
In the embodiment of the application, the instruction type of the instruction determines the processing mode of the message, for example, the instruction type of the instruction is heartbeat information, the message carried in the instruction is a message which is sent by the device to the intelligent internet of things platform and is in a normal state at the moment, and after the intelligent internet of things platform receives the instruction, the message only needs to be forwarded to a corresponding database and the message information is stored; the instruction type of the instruction can also be addition operation, two data in the message data are added, and then the result is forwarded to a corresponding database for storage.
It should be noted that, according to different instruction types of the instruction, the pre-written rule file performs different processing on the message carried in the instruction, and may be directly forwarded and stored in the database, or may be forwarded after parsing according to the parsing rule in the rule file, which is not limited in this application. In addition, the message may be directly forwarded or forwarded after being analyzed, which may be forwarded to a different location according to the actual situation, for example, the message may be forwarded to another data processing Topic, a third party service, a message queue, a database, a Topic of another device, and the like, which is not limited in this application.
Through the above description of the technical scheme provided by the embodiment of the application, when the intelligent internet of things platform obtains an instruction uploaded by the device to the platform or the platform issues an instruction to the device, the message processing method of the application analyzes the message carried in the instruction to be processed by using the original analysis rule of the intelligent internet of things platform, if the analysis is successful, the original analysis rule is directly used for analysis, if the analysis is not successful, the intelligent internet of things platform goes to the database to obtain a pre-compiled rule file, and the rule file is an extension of the original analysis rule, so that the instruction which cannot be analyzed by the original analysis rule is processed.
The rule file is independent of the original analysis rule, so that the original program of the intelligent Internet of things platform does not need to be rewritten, the intelligent Internet of things platform does not need to be deployed again, and the influence on the original service is reduced. Meanwhile, the rule file has flexibility, when the intelligent Internet of things platform expands the service scene, the rule file can be compiled and expanded according to actual processing logic, the problem that the existing protocol cannot meet the continuously expanded service scene is solved, and meanwhile, the existing service cannot be influenced.
Different intelligent internet of things platforms all realize a certain specific service, serve specific crowds, and even when a service scene is expanded, the types of equipment are limited, so the intelligent internet of things platforms always have preset white lists, when the intelligent internet of things platform receives an instruction uploaded by the equipment, firstly, whether the equipment uploading the instruction is in the preset white list is judged, and the equipment is determined to be a trusted sender to process the instruction, fig. 2 is an implementation flow schematic diagram of a message processing method when the equipment reports the instruction to the platform, which is provided by the embodiment of the application, and the method can comprise the following steps:
s201: and acquiring the instruction to be processed.
In the embodiment of the present application, a detailed description of obtaining the instruction to be processed is already given in S101, and is not described herein again.
S202: and determining a sender of the instruction to be processed, and judging whether the sender is in a preset white list, wherein a plurality of credible senders are recorded in the preset white list.
In the embodiment of the application, a sender of a to-be-processed instruction is equipment for sending the instruction to an intelligent internet of things platform, and after the equipment sends the instruction to the intelligent internet of things platform, the equipment needs to first judge whether the equipment is in a preset white list of the intelligent internet of things platform, for example, when the equipment logs in a certain platform, the platform needs to first judge whether a login account is stored in a database of the platform, that is, whether the login account is in the preset white list of the platform, and the account can be logged in successfully only if the login account is in the preset white list of the platform.
In this application embodiment, a plurality of trusted senders have been recorded in the intelligence thing of this application allies oneself with the platform and predetermines the white list, for example when intelligence thing allies oneself with the platform for intelligent student's card platform, student's equipment sends the instruction to intelligence student's card platform, only when student's equipment when in the preset white list of this intelligence student's card platform, this instruction just can be received to intelligence student's card platform, otherwise this equipment is not the trusted sender of this intelligence student's card platform, intelligence student's card platform can't receive the instruction. In addition, the intelligent internet of things platform can be other platforms, and white lists can be preset for different intelligent internet of things platforms.
S203: and if the sender is in the preset white list, analyzing the message carried in the instruction to be processed by using the original analysis rule.
In this embodiment of the application, a sender uses an original parsing rule of an intelligent internet of things platform to parse a message carried by an instruction, which is reported to the intelligent internet of things platform by a device, in a preset white list of the intelligent internet of things platform, and a detailed description is given in S102 and is not described herein again.
S204: and if the analysis fails, determining the reason of the message analysis failure, wherein the reason comprises an equipment reason, a network reason or a reason that the original analysis rule is not matched with the instruction to be processed.
In the embodiment of the application, if the analysis fails in the analysis process, the reason of the analysis failure is firstly analyzed, whether the reason of the analysis failure is a network reason or an equipment reason or whether the original analysis rule does not contain the analysis rule of the message carried in the instruction to be processed is judged, and different processing measures are taken according to different reasons.
S205: if the reason includes the reason that the original parsing rule is not matched with the instruction to be processed, the pre-programmed rule file is obtained through a hot deployment and loading mode, and the step S207 is executed.
In the embodiment of the application, if it is determined that the reason of the analysis failure is the reason that the original analysis rule is not matched with the instruction to be processed, and the instruction to be processed cannot be processed by using the original service processing logic, the pre-compiled rule file is obtained in a hot deployment and loading mode. A detailed description is given in S103 and is not described here in detail.
In the embodiment of the application, the rule file is obtained in a hot deployment and loading mode without restarting a server, so that the requirement of not influencing the existing service is met.
S206: if the reason is not the reason that the original analysis rule is not matched with the instruction to be processed, triggering an alarm; and jumping to S203.
In the embodiment of the present application, if it is determined that the reason for the analysis failure is not the reason for the mismatch between the original analysis rule and the instruction to be processed, an alarm is triggered according to an actual situation, and the process skips to S203 to analyze the message carried in the instruction to be processed by using the original analysis rule again.
In the embodiment of the present application, the reason for triggering the alarm may be a device reason or a network reason, and the present application is not limited herein.
S207: and matching the instruction to be processed with the instruction predefined in the rule file.
S208: and if the matching is successful, acquiring the instruction type of the predefined instruction in the rule file.
S209: and processing the message carried in the instruction to be processed according to the instruction type.
In the embodiment of the present application, detailed descriptions of S207 to S209 are already given in S104 to S106, and are not described herein again.
In the embodiment of the application, the pre-written rule file comprises a rule name, a statement whether the judgment instruction matches with the statement, a statement for analyzing the message, and a statement for forwarding the message. For example, a predefined rule name is "rule-01", and a message with a matching instruction name of "SET _ DATA _ TO _ REDIS" is directly forwarded TO a REDIS database after matching is successful, and is stored in the REDIS database, where the following is a specific implementation code:
rule"rule-01"
when
$p:PacketMsg($p.funId=="SET_DATA_TO_REDIS")
then
println ("rule engine internal matching success SET _ DATA _ TO _ REDIS ═ plus $ p);
ObjectMapper objectMapper=new ObjectMapper();
try{
String str=objectMapper.writeValueAsString($p);
redisTemplate.opsForValue().set("SET_DATA_TO_REDIS",str,12,TimeUnit.HOURS);
}catch(Exception e){
e.printStackTrace();
}
end
in the embodiment of the present application, for example, a predefined rule name is "rule-02", and a message with a matching instruction name of "SET _ DATA _ TO _ MySQL" is directly forwarded TO the MySQL database after matching is successful, and is stored in the MySQL database, where the following is a specific implementation code:
rule"rule-02"
when
$p:PacketMsg($p.funId=="SET_DATA_TO_MYSQL")
then
println ("rule engine internal matching success SET _ DATA _ TO _ MYSQL ═, + $ p);
ObjectMapper objectMapper=new ObjectMapper();
try{
String str=objectMapper.writeValueAsString($p);
userDeviceMapper.saveMessage("device_command_roport",",fun_id,content",$p.getFunId()+","+str);
}catch(Exception e){
e.printStackTrace();
}
end
in this embodiment of the present application, for example, a predefined rule name is "rule-03", and a message with a matching instruction name of "SET _ DATA _ TO _ rocket message q" is directly forwarded TO a rocket message queue after matching is successful, and is stored in the rocket message queue, where the following is a specific implementation code:
rule"rule-03"
when
$p:PacketMsg($p.funId=="SET_DATA_TO_ROCKETMQ")
then
println ("rule engine internal matching success SET _ DATA _ TO _ rocket ═" + $ p);
ObjectMapper objectMapper=new ObjectMapper();
try{
String str=objectMapper.writeValueAsString($p);
rocketMQTemplate.syncSend("SET_DATA_TO_ROCKETMQ",str);
}catch(Exception e){
e.printStackTrace();
}
end
it should be noted that the rule file codes given in the embodiments of the present application are only examples given, different functions may be implemented according to different service requirements in an actual writing process, and the rule name, the instruction name, the processing of the message data before forwarding, and the forwarding position may all be defined according to an actual situation, which is not limited in the present application.
Through the above description of the technical scheme provided by the embodiment of the application, whether the equipment for uploading the instruction is in the preset white list of the intelligent internet of things platform or not is judged, and when the analysis fails, the reason of the analysis failure is judged, and if the failure reason is not that the original analysis rule cannot analyze the uploading instruction, whether the problem is caused by other factors such as the network and the equipment or not is judged, so that the analysis failure is caused.
In addition, the reason for the analysis failure may also be that the device reports an instruction to the platform with an error, fig. 3 is a schematic diagram of an implementation flow of another method for processing a message when the device reports an instruction to the platform, which is provided in the embodiment of the present application, and details a situation that the device reports an instruction to the platform with an error, where the method may include the following steps:
s301: and acquiring the instruction to be processed.
S302: and determining a sender of the instruction to be processed, and judging whether the sender is in a preset white list, wherein a plurality of credible senders are recorded in the preset white list.
S303: and if the sender is in the preset white list, analyzing the message carried in the instruction to be processed by using the original analysis rule.
In the embodiment of the present application, detailed descriptions of S301 to S303 are already given in S201 to S203, and are not described herein again.
S304: if the analysis fails, whether the instruction to be processed is normal is detected.
In the embodiment of the application, in the process of uploading the instruction to the platform by the device, the instruction may be damaged due to various reasons, and the message carried in the instruction is incomplete, so that whether the instruction to be processed is normal or not is judged after the instruction to be processed fails to be analyzed by using the original analysis rule in the intelligent internet of things platform. For example, in the process of message transmission, the message data is transmitted in a form of ciphertext, the message data is encrypted before being transmitted from the device, and is decrypted after being transmitted to the platform, and in the process of encryption or decryption, errors such as missing of the message data may occur, and at this time, the parsing may fail.
For example, the message data and the corresponding ciphertext are as follows:
original message string 1:
[868560040058335,89860317947552295702,202202231403130022,SET_DATA_TO_REDIS,3,20220223140313,1,1]
encrypted ciphertext 1:
WYkXNVBigZnYr2gQS2O+uRHheV52ONbMsnxfZ/PONPCdOBGZe00NOiIOe6MmhaLsGPXJraFvL2SiQQYZ1pxM9STArYmnuM6OSWNQE7H1TMmy+WyTpJTH5dHO3dnKgdzS3o4po6Es3PW2Vh+OS7NIag==#TELPO#1.2.2#1.2.0
original message string 2:
[868560040058335,89860317947552295702,202202231403130022,SET_DATA_TO_ROCKETMQ,3,20220223140313,1,1]
encrypted ciphertext 2:
WYkXNVBigZnYr2gQS2O+uRHheV52ONbMsnxfZ/PONPCdOBGZe00NOiIOe6MmhaLsGPXJraFvL2SiQQYZ1pxM9WTYi9/4ZC3W7wD7BuiuK2e0xokrnios1ob/v59LkWamAj8iKU1C8WHxNv8kXySqJQ==#TELPO#1.2.2#1.2.0
original message string 3:
[868560040058335,89860317947552295702,202202231403130022,SET_DATA_TO_MYSQL,3,20220223140313,1,1]
encrypted ciphertext 3:
WYkXNVBigZnYr2gQS2O+uRHheV52ONbMsnxfZ/PONPCdOBGZe00NOiIOe6MmhaLsGPXJraFvL2SiQQYZ1pxM9Y6J7UbQYkHzZGcAzR0tAl1UTAgmkXINTWoiU5BntXX52zNGgDLv8FEvVb3p7j3zpQ==#TELPO#1.2.2#1.2.0
because the message data and the corresponding message character string are very long, the loss and dislocation of the character string can be generated due to various reasons in the encryption and decryption processes, so that various errors occur in the message, and the method is not limited in the application.
In addition, other exceptions may be generated by the pending instruction in the present application, which is not limited in the present application.
S305: if the instruction to be processed is normal, the pre-programmed rule file is obtained in a hot deployment and loading manner, and S307 is executed.
In the embodiment of the application, if the instruction uploaded to the platform by the device is normal and is not damaged, the pre-programmed rule file is acquired in a hot deployment and loading mode. A detailed description is given in S103 and is not described here in detail.
S306: if the instruction to be processed is abnormal, triggering an alarm of the instruction abnormality, and ending the process.
In the embodiment of the application, if the instruction to be processed is abnormal, the instruction abnormity alarm is triggered, the instruction abnormity alarm can transmit a prompt message to the equipment through the platform to prompt that the instruction is abnormal, and the equipment uploads the instruction again. In addition, the instruction exception warning to be processed can also be displayed in other modes, and the method is not limited in the application.
S307: and matching the instruction to be processed with the instruction predefined in the rule file.
S308: and if the matching is successful, acquiring the instruction type of the predefined instruction in the rule file.
S309: and processing the message carried in the instruction to be processed according to the instruction type.
In the embodiment of the present application, detailed descriptions of S307 to S309 are already given in S104 to S106, and are not repeated herein.
Through the above description of the technical scheme provided by the embodiment of the application, when the intelligent internet of things platform obtains an instruction uploaded by the device, it is first determined whether the device is in the preset white list, and the instruction uploaded by the device is processed only when the device is in the preset white list. When the analysis of the message data carried in the instruction fails, the reason of the analysis failure is judged firstly, the reason of the analysis failure comprises multiple kinds, the analysis rule is not matched with the uploaded instruction, the external reasons such as network reason and equipment reason are included, the instruction uploaded by the equipment is abnormal, the rule file is obtained only when the original analysis rule is not matched with the uploaded instruction, the rule matching is carried out, and other conditions give an alarm according to specific reasons.
Fig. 4 is a schematic implementation flow diagram of another message processing method according to an embodiment of the present application, where the method includes the following steps:
s401: and acquiring the instruction to be processed.
S402: and analyzing the message carried in the instruction to be processed by utilizing the original analysis rule.
S403: and if the analysis fails, acquiring a pre-compiled rule file.
S404: and matching the instruction to be processed with the instruction predefined in the rule file.
S405: and if the matching is successful, acquiring the instruction type of the predefined instruction in the rule file.
In the embodiment of the present application, detailed descriptions of S401 to S405 are already given in S101 to S105, and are not repeated herein.
S406: and analyzing the message carried in the instruction to be processed according to the analysis rule corresponding to the instruction type to obtain the analyzed message.
In the embodiment of the application, different instruction types correspond to different analysis rules, for example, when the instruction type is heartbeat information, the corresponding analysis rule is that the equipment for recording and sending the heartbeat information normally operates; when the instruction type is an addition type, the parsing rule may be to add data in the message, and the calculated result is the parsed message. In addition, the instruction type may also include other types, so as to correspond to different parsing rules, where the different parsing rules are defined by a person writing the rules according to a service to be processed, and this is not limited in this application.
S407: and searching a message forwarding position corresponding to the instruction type, and forwarding the analyzed message according to the message forwarding position.
In this embodiment of the application, the instruction type determines a position to which the analyzed message is to be forwarded, and after the message is analyzed according to a predefined analysis rule in S406, the message needs to be forwarded, for example, when the instruction type is heartbeat information, after the platform acquires a normal message of the device, the platform needs to store the information in the message, record information of the normal device, time when the device normally sends the heartbeat information, and the like, so that when the device is abnormal later, when it is determined that the instruction type is the heartbeat information, the smart internet of things platform needs to forward the message to the position, and forward the heartbeat information according to the position.
In addition, different pointer types can analyze the message according to different analysis rules, and then forward the message to different positions, and can forward the message to a MySQL database, a non-relational database, a message queue and the like, which is not limited in the present application.
Through the above description of the technical solution provided in the embodiment of the present application, when the rule file is used to analyze the instruction to be processed, the predefined instruction in the rule file needs to be matched, the instruction type of the predefined instruction in the rule file is obtained, and the operation of processing and forwarding the instruction to be processed is performed according to the instruction type.
Fig. 5 is a schematic structural diagram of a message processing apparatus according to an embodiment of the present application, where the apparatus includes: the system comprises an instruction acquisition module 51, an analysis module 52, a rule file acquisition module 53, a rule matching module 54, an instruction type acquisition module 55 and a message processing module 56.
The instruction obtaining module 51: for fetching instructions to be processed.
The parsing module 52: the method is used for analyzing the message carried in the instruction to be processed by utilizing the original analysis rule.
The rule file obtaining module 53: and the rule file is used for acquiring the pre-written rule file if the analysis fails.
The rule matching module 54: for matching the instructions to be processed with the instructions predefined in the rule file.
Instruction type acquisition module 55: and if the matching is successful, acquiring the instruction type of the predefined instruction in the rule file.
The message processing module 56: and the message processing device is used for processing the message carried in the instruction to be processed according to the instruction type.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application, including a processor 61, a communication interface 62, a memory 63, and a communication bus 64, where the processor 61, the communication interface 62, and the memory 63 complete mutual communication through the communication bus 64,
a memory 63 for storing a computer program;
the processor 61 is configured to implement the following steps when executing the program stored in the memory 63:
acquiring a command to be processed; analyzing the message carried in the instruction to be processed by using the original analysis rule; if the analysis fails, acquiring a pre-compiled rule file; matching the instruction to be processed with a predefined instruction in the rule file; if the matching is successful, acquiring the instruction type of a predefined instruction in the rule file; and processing the message carried in the instruction to be processed according to the instruction type.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM), and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
An embodiment of the present application further provides a storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the following steps:
acquiring a command to be processed; analyzing the message carried in the instruction to be processed by using the original analysis rule; if the analysis fails, acquiring a pre-compiled rule file; matching the instruction to be processed with a predefined instruction in the rule file; if the matching is successful, acquiring the instruction type of a predefined instruction in the rule file; and processing the message carried in the instruction to be processed according to the instruction type.
In yet another embodiment provided by the present application, a computer program product containing instructions is also provided, which when run on a computer causes the computer to perform any of the message processing methods in the above embodiments.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is merely exemplary of the present application and is presented to enable those skilled in the art to understand and practice the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (10)
1. A message processing method is applied to an intelligent Internet of things platform, and comprises the following steps:
acquiring a command to be processed;
analyzing the message carried in the instruction to be processed by using the original analysis rule;
if the analysis fails, acquiring a pre-compiled rule file;
matching the instruction to be processed with a predefined instruction in the rule file;
if the matching is successful, acquiring the instruction type of the predefined instruction in the rule file;
and processing the message carried in the instruction to be processed according to the instruction type.
2. The method of claim 1, wherein said fetching pending instructions comprises:
receiving an instruction reported to the platform by the equipment;
or the like, or a combination thereof,
and acquiring an instruction issued by the platform to the equipment.
3. The method of claim 1, wherein obtaining a pre-compiled rule file comprises:
and acquiring a pre-written rule file in a hot deployment and loading mode.
4. The method according to claim 1, wherein the processing the packet carried in the instruction to be processed according to the instruction type includes:
analyzing the message carried in the instruction to be processed according to an analysis rule corresponding to the instruction type, and acquiring the analyzed message;
and searching a message forwarding position corresponding to the instruction type, and forwarding the analyzed message according to the message forwarding position.
5. The method according to claim 1, wherein the parsing the packet carried in the instruction to be processed by using the original parsing rule includes:
determining a sender of the instruction to be processed, and judging whether the sender is in a preset white list or not, wherein a plurality of credible senders are recorded in the preset white list;
and if the sender is in the preset white list, analyzing the message carried in the instruction to be processed by using the original analysis rule.
6. The method of claim 1, wherein obtaining a pre-compiled rule file if the parsing fails comprises:
if the analysis fails, determining the reason of the message analysis failure, wherein the reason comprises an equipment reason, a network reason or a reason that an original analysis rule is not matched with the instruction to be processed;
if the reason comprises the reason that the original analysis rule is not matched with the instruction to be processed, acquiring a pre-compiled rule file;
if the reason is not the reason that the original analysis rule is not matched with the instruction to be processed, triggering an alarm; and the number of the first and second groups,
and skipping to the step of analyzing the message carried in the instruction to be processed by using the original analysis rule.
7. The method of claim 1, wherein obtaining a pre-compiled rule file if the parsing fails comprises:
if the analysis is failed, detecting whether the instruction to be processed is normal;
if the instruction to be processed is normal, acquiring a pre-compiled rule file;
and if the instruction to be processed is abnormal, triggering an alarm of the instruction abnormity.
8. A message processing device is applied to an intelligent Internet of things platform, and the device comprises:
an instruction acquisition module: the method comprises the steps of obtaining an instruction to be processed;
an analysis module: the message analysis module is used for analyzing the message carried in the instruction to be processed by utilizing the original analysis rule;
a rule file acquisition module: the rule file pre-compiling module is used for acquiring a pre-compiled rule file if the analysis fails;
a rule matching module: the instruction matching module is used for matching the instruction to be processed with a predefined instruction in the rule file;
an instruction type acquisition module: the instruction type of the predefined instruction in the rule file is obtained if the matching is successful;
a message processing module: and the message processing module is used for processing the message carried in the instruction to be processed according to the instruction type.
9. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing the communication between the processor and the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 7 when executing a program stored in the memory.
10. A storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the method of any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210329656.2A CN115065736A (en) | 2022-03-29 | 2022-03-29 | Message processing method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210329656.2A CN115065736A (en) | 2022-03-29 | 2022-03-29 | Message processing method and device, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115065736A true CN115065736A (en) | 2022-09-16 |
Family
ID=83196664
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210329656.2A Pending CN115065736A (en) | 2022-03-29 | 2022-03-29 | Message processing method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115065736A (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107656874A (en) * | 2017-11-07 | 2018-02-02 | 中国银行股份有限公司 | A kind of interface test method, device, simulation baffle plate and system |
WO2018076769A1 (en) * | 2016-10-26 | 2018-05-03 | 中兴通讯股份有限公司 | Information processing method and apparatus |
CN110012002A (en) * | 2019-03-29 | 2019-07-12 | 深圳智链物联科技有限公司 | Message parsing method, device and server, computer readable storage medium |
CN110188135A (en) * | 2019-05-30 | 2019-08-30 | 中国联合网络通信集团有限公司 | Document generating method and equipment |
CN111327625A (en) * | 2020-03-02 | 2020-06-23 | 武汉中旗生物医疗电子有限公司 | Parameter monitoring method and device, multi-parameter monitor and storage medium |
CN112286968A (en) * | 2020-10-23 | 2021-01-29 | 北京三快在线科技有限公司 | Service identification method, equipment, medium and electronic equipment |
CN112468413A (en) * | 2020-11-26 | 2021-03-09 | 迈普通信技术股份有限公司 | Message processing method and device, electronic equipment and storage medium |
CN113065139A (en) * | 2021-05-06 | 2021-07-02 | 携程旅游网络技术(上海)有限公司 | Alarm access method and system, electronic device and medium |
CN113765857A (en) * | 2020-06-04 | 2021-12-07 | 华为技术有限公司 | Message forwarding method, device, equipment and storage medium |
-
2022
- 2022-03-29 CN CN202210329656.2A patent/CN115065736A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2018076769A1 (en) * | 2016-10-26 | 2018-05-03 | 中兴通讯股份有限公司 | Information processing method and apparatus |
CN107656874A (en) * | 2017-11-07 | 2018-02-02 | 中国银行股份有限公司 | A kind of interface test method, device, simulation baffle plate and system |
CN110012002A (en) * | 2019-03-29 | 2019-07-12 | 深圳智链物联科技有限公司 | Message parsing method, device and server, computer readable storage medium |
CN110188135A (en) * | 2019-05-30 | 2019-08-30 | 中国联合网络通信集团有限公司 | Document generating method and equipment |
CN111327625A (en) * | 2020-03-02 | 2020-06-23 | 武汉中旗生物医疗电子有限公司 | Parameter monitoring method and device, multi-parameter monitor and storage medium |
CN113765857A (en) * | 2020-06-04 | 2021-12-07 | 华为技术有限公司 | Message forwarding method, device, equipment and storage medium |
CN112286968A (en) * | 2020-10-23 | 2021-01-29 | 北京三快在线科技有限公司 | Service identification method, equipment, medium and electronic equipment |
CN112468413A (en) * | 2020-11-26 | 2021-03-09 | 迈普通信技术股份有限公司 | Message processing method and device, electronic equipment and storage medium |
CN113065139A (en) * | 2021-05-06 | 2021-07-02 | 携程旅游网络技术(上海)有限公司 | Alarm access method and system, electronic device and medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108427616B (en) | Background program monitoring method and monitoring device | |
US10037238B2 (en) | System and method for encoding exception conditions included at a remediation database | |
US20220050765A1 (en) | Method for processing logs in a computer system for events identified as abnormal and revealing solutions, electronic device, and cloud server | |
CN105472417B (en) | Method and device for acquiring video player abnormity | |
CN111552633A (en) | Interface abnormal call testing method and device, computer equipment and storage medium | |
CN113240258A (en) | Industrial asset detection method, equipment and device | |
CN107277019B (en) | Data plaintext acquisition method and device, electronic terminal and readable storage medium | |
CN111756697B (en) | API safety detection method and device, storage medium and computer equipment | |
CN107844385B (en) | Variable read-write method and device based on shared memory | |
CN111198797B (en) | Operation monitoring method and device and operation analysis method and device | |
CN110969417A (en) | Government affair item synchronization method, device, system, computer equipment and storage medium | |
CN110995522B (en) | Information processing method and device | |
CN111586022A (en) | Firewall opening verification method, electronic device, computer equipment and storage medium | |
CN109150587B (en) | Maintenance method and device | |
CN115065736A (en) | Message processing method and device, electronic equipment and storage medium | |
CN112416735B (en) | Application program detection method and device, terminal equipment and storage medium | |
CN110752963B (en) | Event processing method and device, storage medium and electronic device | |
CN115357513B (en) | Program ambiguity test method, device, equipment and storage medium | |
CN116450471A (en) | Alarm method and device for abnormal log, storage medium and computer equipment | |
CN112395194B (en) | Method and device for accessing test platform | |
CN114968822A (en) | Interface testing method and device, computer equipment and storage medium | |
CN114205422A (en) | Non-invasive service processing method, device, equipment and storage medium | |
CN114416560A (en) | Program crash analysis aggregation method and system | |
CN109634931B (en) | Log uploading method and device | |
CN114675989A (en) | Data verification method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20220916 |