A message processing method and apparatus
By receiving and broadcasting message requests between the software systems, using system encoding and operation encoding to determine the message processing content, and returning the processing results, the problem of strong dependence and high coupling between the software systems is solved, and the effect of reducing coupling and improving interaction stability is achieved.
Patent Information
- Application Number
- CN202010230750.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-27
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2040-03-27
AI Technical Summary
The existing software systems have strong dependence and high coupling, which leads to the system call method that must rely on the interface provided by the other party. Modifying a single interface may affect many systems. The call of the system interface has network delays and interrupts, resulting in the call failure, and the network transmission between the system interface and the interface may be at risk of data leakage.
By receiving a message request sent by the first system, including system encoding, operation encoding and message content, the message request is broadcast, so that other systems can determine the processing message content based on the system encoding and operation encoding, and receive processing results sent by other systems to send to the first system.
It reduces the coupling between systems, improves the stability of interactive data between systems, reduces the network delay problems and risks of transmission between systems, and reduces the dependence between systems.
Smart Images

Figure CN113452739B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a message processing method and apparatus. Background Art
[0002] With the development of Internet services, there are various relationships and couplings among various software systems. Currently, the following are several popular ways of interaction between systems:
[0003] Based on interface definition and publication, that is, based on the microservice remote RPC call method. Among them, RPC is the full name of Remote Procedure Call, remote procedure call, which is a protocol for requesting services from a remote computer program through a network without the need to understand the underlying network technology.
[0004] And a method based on a generalized call for invocation, such as by defining the name and method of an interface, etc. In addition, there is also an interface based on the HTTP request REST style for access. Among them, Representational State Transfer, abbreviated as REST, is a design and development method for network applications, which can reduce the complexity of development and improve the scalability of the system.
[0005] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0006] The system call method must rely on the interface provided by the other party. If the system is directly associated with too many other systems, too many interfaces may be defined. When the same service is connected to different systems, it is necessary to apply and rely on the return results of the interfaces of the other party, and when the interface name and parameters of the calling party change, the configuration needs to be modified. Therefore, the dependency between systems is high. Summary of the Invention
[0007] In view of this, embodiments of the present invention provide a message processing method and apparatus, which can solve the problem of strong dependence and high coupling degree among existing software systems.
[0008] To achieve the above object, according to one aspect of the embodiments of the present invention, a message processing method is provided, including receiving a message request sent by a first system; wherein, the message request includes a system code, an operation code, and a message content; broadcasting the message request, so that other systems determine to process the message content according to the system code and the operation code in the message request; receiving the processing result of the message request sent by other systems, so as to send the processing result to the first system.
[0009] Optionally, so that other systems determine to process the message content according to the system code and the operation code in the message request, including:
[0010] Other systems obtain the system code in the message request and determine whether it is the code of the other systems;
[0011] According to the judgment result, if so, process the message content according to the operation code and return the processing result; if not, skip the message request.
[0012] Optionally, processing the message content according to the operation code and returning the processing result includes:
[0013] When the processing result of processing the message content according to the operation code is abnormal, the other system throws an exception.
[0014] Optionally, processing the message content according to the operation code and returning the processing result includes:
[0015] Based on a preset operation code table, the other system looks up whether there is an operation code in the message request. If there is, process the message content according to the operation code and return the processing result; if not, return result information in a preset format.
[0016] Optionally, it includes:
[0017] If the processing result of the message request sent by another system is abnormal, the message request is broadcast again until a processing result of successful consumption is received.
[0018] Optionally, after receiving the processing result of the message request sent by another system, it further includes:
[0019] Save the processing result to the message server.
[0020] In addition, the present invention further provides a message processing device, including a first module for receiving a message request sent by a first system; wherein, the message request includes a system code, an operation code, and message content; a second module for broadcasting the message request, so that other systems determine to process the message content according to the system code and operation code in the message request; a third module for receiving the processing result of the message request sent by another system to send the processing result to the first system.
[0021] Optionally, the third module is further configured to:
[0022] If the processing result of the message request sent by another system is abnormal, the message request is broadcast again until a processing result of successful consumption is received.
[0023] One embodiment of the above invention has the following advantages or beneficial effects: By receiving a message request sent by a first system, where the message request includes a system code, an operation code, and a message content, broadcasting the message request, enabling other systems to determine how to process the message content based on the system code and operation code in the message request, and receiving the processing result of the message request sent by other systems to send the processing result to the first system, the technical problem of strong dependence and high coupling degree between existing software systems is overcome. Furthermore, the technical effects of reducing the coupling degree between systems, improving the stability of interactive data between systems, and reducing the network latency problem and risk in the transmission between systems are achieved.
[0024] The further effects of the above non-conventional alternative methods will be described below in combination with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings are used to better understand the present invention and do not unduly limit the present invention. Among them:
[0026] Figure 1 is a schematic diagram of the main process of the message processing method according to the first embodiment of the present invention;
[0027] Figure 2 is a schematic diagram of the main process of the message processing method according to the second embodiment of the present invention;
[0028] Figure 3 is a schematic diagram of the main process of processing the message content according to the embodiment of the present invention;
[0029] Figure 4 is a schematic diagram of the main modules of the message processing device according to the embodiment of the present invention;
[0030] Figure 5 is an exemplary system architecture diagram to which the embodiment of the present invention can be applied;
[0031] Figure 6 is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing the embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0032] The following describes exemplary embodiments of the present invention with reference to the accompanying drawings. Various details of the embodiments of the present invention are included to assist understanding and should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted below.
[0033] Figure 1 It is a schematic diagram of the main process of the message processing method according to the first embodiment of the present invention. As Figure 1 shown, the message processing method includes:
[0034] Step S101, receiving a message request sent by the first system; wherein, the message request includes a system code, an operation code, and a message content.
[0035] In the embodiment, each system (A, B, C... N) defines a system code (such as SystemA), an operation code (such as operatorA), and a message content according to the business needs between the systems. For example: If system A needs to obtain whether a certain device of system B has been initialized, the system code SystemB and the operation code deviceInit (device initialization code) are defined in the message request. If system A needs to obtain whether a certain device of system B is configured completely, the system code SystemB and the operation code: deviceConfig (device configuration) are defined in the message request.
[0036] Furthermore, each message request can also set a message identifier topic, that is, the format of the message request is: message identifier, system code, operation code, message content.
[0037] It should be noted that the message convention between each system can be uniformly managed and set by the message server. Of course, the message server can execute step S101 to step S103. Among them, the message server, as a node of the network, is specifically used to store and forward data and information on the network.
[0038] In a preferred embodiment, the message server can receive the message requests with system codes and operation codes sent by each system (A, B, C... N) according to their own business requirements. If it fails, the system will resend until it succeeds.
[0039] Step S102, broadcasting the message request, so that other systems can determine to process the message content according to the system code and operation code in the message request.
[0040] In the embodiment, the message server receives the message requests of each system and then broadcasts and sends them out. Thus, each system can receive other message requests except the message requests it sends itself. That is, each system can determine whether to process the message content according to the system code and operation code in the message request, or it can also be said that each system can determine whether to consume the message content according to the system code and operation code in the message request.
[0041] As some embodiments, when other systems determine how to process the message content based on the system code and operation code in the message request, the other systems obtain the system code in the message request and determine whether it is the code of the other system. According to the judgment result, if it is, the message content is processed according to the operation code and the processing result is returned; if not, the message request is skipped.
[0042] In a further embodiment, if the processing result of processing the message content according to the operation code is abnormal, the other system throws an exception.
[0043] That is to say, each system (A, B, C... N) determines whether to consume the message content according to its own business needs. If not, it directly skips; if so, it processes the message and concurrently sends the processing result back to the message server. If an exception occurs during processing, an exception is thrown. The message server will resend the broadcast message, and each system (A, B, C... N) will consume the message again until the consumption is successful. Therefore, the high availability of the message is ensured, and each system does not need to have high availability and can process the message when the system is normal.
[0044] In addition, when processing the message content according to the operation code, the other system can also search for the operation code in the message request based on a preset operation code table. If it exists, the message content is processed according to the operation code and the processing result is returned; if not, a result message in a preset format (e.g., "undefined operation code") is returned.
[0045] Step S103: Receive the processing result of the message request sent by another system to send the processing result to the first system.
[0046] As a preferred embodiment, if an abnormal processing result of the message request sent by another system is received, the message request is broadcast again until a processing result of successful consumption is received.
[0047] It is also worth noting that after receiving the processing result of the message request sent by another system, the processing result can be saved in the message server. That is to say, the processing result does not need to be retained in each system but is directly saved in the message server, only requiring the high availability of the message server, thereby realizing the persistence of the message processing result.
[0048] In summary, the message processing method proposed by the present invention solves the problems that the call dependencies between systems are very strong, modifying a single interface may affect many systems, and the coupling degree between systems is high. Moreover, it solves the problem that there are certain network delays and interruptions in the call of interfaces between systems, resulting in call failures. And the problem that the call speed between system interfaces through network transmission is affected and there may be a risk of data leakage in network transmission. At the same time, it solves the problem that each system in the call between systems must have high availability, otherwise it will fail. That is to say, the present invention avoids the problems of high coupling degree between systems, network transmission risks, and the need for high real-time availability of systems.
[0049] Figure 2 FIG. is a schematic diagram of the main process of the message processing method according to the second embodiment of the present invention. The message processing method may include:
[0050] Step S201, receiving a message request sent by a first system. Among them, the message request includes a system code, an operation code, and a message content.
[0051] Step S202, broadcasting the message request, so that other systems determine to process the message content according to the system code and operation code in the message request.
[0052] Step S203, determining whether the processing result of the message request received from other systems is abnormal. If so, return to step S202; otherwise, proceed to step S204.
[0053] Step S204, storing the processing result.
[0054] Step S205, sending the stored processing result to the first system.
[0055] Figure 3 FIG. is a schematic diagram of the main process of processing message content according to an embodiment of the present invention, including:
[0056] Step S301, other systems obtain the system code in the message request.
[0057] Step S302, determining whether it is the code of this other system. If so, proceed to step S303; if not, skip the message request.
[0058] Step S303, based on a preset operation code table, this other system searches for the operation code in the message request. If it exists, proceed to step S304; if not, return the result information in a preset format.
[0059] Step S304, processing the message content according to the operation code.
[0060] Step S305: Determine whether the processing result of the processed message content is abnormal. If it is, proceed to Step S306; otherwise, proceed to Step S307.
[0061] Step S306: The other system throws an execution exception.
[0062] Step S307: Return the processing result.
[0063] In summary, the present invention separates interface dependencies. By agreeing on unified interaction rules among various systems, based on system coding, operation coding, etc., and then using a highly available message system to uniformly receive and distribute, the interaction between business systems can be achieved, reducing the coupling degree and improving the stability of the system.
[0064] In addition, the present invention realizes that on the one hand, it is sent to the message server, and on the other hand, it receives from the message server without mutual influence. Nodes between systems can be added and deleted at any time without affecting the use of other systems, thereby reducing the coupling degree between systems. Since there is only internal message interaction between systems, network propagation is reduced, the risk of data network delay is reduced, and efficiency is improved. At the same time, since only the high availability of the message server needs to be ensured, the data stability between systems is also improved a lot, and the stability requirements of each system can be relatively lower.
[0065] Figure 4 It is a schematic diagram of the main modules of the message processing device according to an embodiment of the present invention. As Figure 4 shown, the message processing device 400 includes a first module 401, a second module 402, and a third module 403. Among them, the first module 401 receives a message request sent by the first system; the message request includes a system coding, an operation coding, and a message content. The second module 402 broadcasts the message request, so that other systems determine the processed message content according to the system coding and operation coding in the message request. The third module 403 receives the processing result of the message request sent by other systems to send the processing result to the first system.
[0066] In some embodiments, the third module 403 is further configured to:
[0067] If the processing result of the message request sent by other systems is abnormal, broadcast the message request again until a processing result of successful consumption is received.
[0068] As another embodiment of the present invention, so that other systems determine the processed message content according to the system coding and operation coding in the message request, including:
[0069] Other systems obtain the system code in the message request and determine whether it is the code of that other system; according to the judgment result, if so, process the message content according to the operation code and return the processing result, if not, skip the message request.
[0070] Preferably, processing the message content according to the operation code and returning the processing result includes:
[0071] When the processing result of processing the message content according to the operation code is abnormal, then that other system performs an exception throw.
[0072] Another preferred embodiment, processing the message content according to the operation code and returning the processing result includes:
[0073] Based on a preset operation code table, that other system looks up whether there is an operation code in the message request. If there is, process the message content according to the operation code and return the processing result. If not, return the result information in a preset format.
[0074] As still other embodiments of the present invention, the third module 403 may also be used to receive that the processing result of the message request sent by another system is abnormal, and then broadcast the message request again until a processing result of successful consumption is received.
[0075] It is also worth noting that after the third module 403 receives the processing result of the message request sent by another system, it may also save the processing result to the message server.
[0076] It should be noted that there is a corresponding relationship between the message processing method and the message processing device of the present invention in terms of specific implementation content, so the repeated content will not be described again.
[0077] Figure 5 An exemplary system architecture 500 to which the message processing method or the message processing device of the embodiments of the present invention can be applied is shown.
[0078] As Figure 5 shown, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used to provide a medium for a communication link between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0079] Users can use terminal devices 501, 502, and 503 to interact with server 505 via network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, and 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (for example only).
[0080] Terminal devices 501, 502, and 503 can be various electronic devices with a message processing screen and supporting web browsing, including but not limited to smartphones, tablets, laptop computers, desktop computers, and so on.
[0081] Server 505 can be a server that provides various services, such as a background management server that supports shopping websites browsed by users using terminal devices 501, 502, and 503 (for example only). The background management server can analyze and process data such as product information query requests received, and feedback the processing results (such as target push information, product information - for example only) to the terminal device.
[0082] It should be noted that the message processing method provided by the embodiments of the present invention is generally executed by server 505. Correspondingly, the computing device is generally disposed in server 505.
[0083] It should be understood that Figure 5 the numbers of terminal devices, networks, and servers in
[0084] are merely illustrative. According to the implementation requirements, there can be any number of terminal devices, networks, and servers. Figure 6 The following refers to Figure 6 which shows a schematic structural diagram of a computer system 600 of a terminal device suitable for implementing the embodiments of the present invention.
[0085] As Figure 6 shown, computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage section 608 into the random access memory (RAM) 603. In RAM 603, various programs and data required for the operation of computer system 600 are also stored. CPU 601, ROM 602, and RAM 603 are connected to each other via bus 604. The input / output (I / O) interface 605 is also connected to bus 604.
[0086] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as required. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive 610 as required so that a computer program read therefrom is installed into the storage section 608 as required.
[0087] Specifically, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product including a computer program carried on a computer-readable medium, the computer program including program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from the removable medium 611. When the computer program is executed by a central processing unit (CPU) 601, the above-described functions defined in the system of the present invention are performed.
[0088] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0089] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0090] The modules involved in the embodiments of the present invention can be implemented in software or in hardware. The described modules can also be provided in a processor. For example, it can be described as: a processor includes a first module, a second module, and a third module. Among them, the names of these modules do not constitute a limitation on the modules themselves in some cases.
[0091] As another aspect, the present invention also provides a computer-readable medium. The computer-readable medium can be included in the device described in the above embodiments; or it can exist alone without being assembled into the device. The above computer-readable medium carries one or more programs. When the one or more programs are executed by the device, the device includes receiving a message request sent by a first system; wherein, the message request includes a system code, an operation code, and a message content; broadcasting the message request, so that other systems determine how to process the message content according to the system code and the operation code in the message request; receiving the processing result of the message request sent by other systems to send the processing result to the first system.
[0092] According to the technical solution of the embodiments of the present invention, the problem that existing software systems are highly dependent on each other and have a high coupling degree can be solved.
[0093] The above specific embodiments do not limit the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A message processing method, characterized in that, including: receiving a message request sent by a first system; wherein, the message request includes a system code, an operation code, and a message content; broadcasting the message request, so that other systems determine to process the message content according to the system code and the operation code in the message request; receiving a processing result of the message request sent by other systems, so as to send the processing result to the first system.
2. The method according to claim 1, characterized in that, So that other systems determine to process the message content according to the system code and the operation code in the message request, including: other systems obtain the system code in the message request and determine whether it is the code of the other system; according to the judgment result, if so, process the message content according to the operation code and return the processing result, if not, skip the message request.
3. The method according to claim 2, characterized in that, Processing the message content according to the operation code and returning the processing result, including: when the processing result of processing the message content according to the operation code is abnormal, the other system performs an exception throw.
4. The method according to claim 2, characterized in that, Processing the message content according to the operation code and returning the processing result, including: based on a preset operation code table, the other system searches for whether there is an operation code in the message request, if so, processes the message content according to the operation code and returns the processing result, if not, returns a result message in a preset format.
5. The method according to any one of claims 1 - 4, characterized in that, including: receiving that the processing result of the message request sent by other systems is abnormal, then broadcasting the message request again until a processing result of successful consumption is received.
6. The method according to claim 1, characterized in that, After receiving the processing result of the message request sent by other systems, it further includes: saving the processing result to a message server.
7. A message processing device, characterized in that, including: a first module, configured to receive a message request sent by a first system; wherein, the message request includes a system code, an operation code, and a message content; a second module, configured to broadcast the message request, so that other systems determine to process the message content according to the system code and the operation code in the message request; a third module, configured to receive a processing result of the message request sent by other systems, so as to send the processing result to the first system.
8. The device according to claim 7, characterized in that, The third module is further configured to: receive that the processing result of the message request sent by other systems is abnormal, then broadcast the message request again until a processing result of successful consumption is received.
9. An electronic device, characterized in that, including: one or more processors; a storage device, configured to store one or more programs, when the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the method according to any one of claims 1-6.
10. A computer-readable medium, on which a computer program is stored, characterized in that, When the program is executed by the processor, it implements the method according to any one of claims 1-6.
Citation Information
Patent Citations
Method and system for searching node
CN102014456A