Micro front-end message communication method and device based on central message proxy

By introducing a central message agent into the micro front-end architecture, establishing message subscription and publishing relationship mapping, and using message queues, the problems of low message communication efficiency and poor scalability in the micro front-end architecture are solved, real-time message delivery and flexible expansion are achieved, and improved Improve communication efficiency and system performance.

CN118656234APending Publication Date: 2024-09-17THE SECOND RES INST OF CIVIL AVIATION ADMINISTRATION OF CHINA +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410853117.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

In the micro front-end architecture, the existing HTTP request or WebSocket message communication methods lead to increased network overhead, reduced communication efficiency, unstable message delivery, and lack of flexible and accurate message delivery and scalability.

Method used

Adopt a micro-front-end message communication method based on the central message agent, register the main application as the central message agent component, establish the relationship mapping between subscriber sub-applications and message topic types, realize message subscription and publishing, and use message queues for asynchronous storage and broadcast. Improve communication efficiency and scalability.

Benefits of technology

It realizes real-time message transmission between sub-applications, reduces network overhead, supports flexible message expansion mechanism, meets complex message communication requirements, and improves the response speed and scalability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656234A
    Figure CN118656234A
Patent Text Reader

Abstract

The invention provides a micro-front-end message communication method and device based on a central message proxy, applied to a main application in a micro-front-end architecture, the main application is registered as a central message proxy component, and the central message proxy component is used for opening a corresponding message communication interface for each sub-application; determining a message subscription request sent by a message communication interface called by the subscriber sub-application, and constructing relation mapping between the subscriber sub-application and a message theme type carried in the message subscription request; in response to a message publishing request sent by the message communication interface called by the message publisher sub-application, receiving a target theme message corresponding to the message publishing request; and broadcasting the target theme message to the corresponding subscriber sub-application according to the relational mapping. Real-time message transmission between sub-applications can be realized, the communication efficiency is improved, the network overhead is reduced, a flexible message expansion mechanism is supported, and various complex message communication requirements are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data communication technology, and in particular to a micro-front-end message communication method and device based on a central message agent. Background Art

[0002] In the current software development field, micro-frontend architecture has gradually become a popular solution. Micro-frontend architecture splits the front-end application into multiple independent sub-applications, each of which can be independently developed, deployed and maintained, thereby improving the independence and development efficiency of the team.

[0003] At present, in the micro-frontend architecture, sub-applications mainly use HTTP requests or WebSockets for message communication. This solution can realize message transmission between sub-applications, but the current message communication method will incur additional network overhead. Using HTTP requests or WebSockets for communication requires establishing and maintaining network connections, which increases additional network overhead and reduces communication efficiency. At the same time, since each communication needs to be transmitted through the network, the message transmission speed is affected by factors such as network delay and bandwidth. Data packet loss, data backlog, data storms and other problems may occur, resulting in instability in the message transmission process. Furthermore, the existing solution is not flexible enough to support the precise delivery of messages, and cannot meet complex message communication requirements, resulting in the problem of limited precise message delivery. In addition, the existing solution may face some difficulties when expanding new sub-applications, requiring major changes and adjustments, and lacks scalability. Summary of the invention

[0004] The embodiments of the present disclosure at least provide a micro-front-end message communication method and device based on a central message agent, which can realize real-time message transmission between sub-applications, improve communication efficiency, reduce network overhead, and support flexible message expansion mechanism to meet various complex message communication needs.

[0005] The embodiment of the present disclosure provides a micro-frontend message communication method based on a central message agent, which is applied to a main application in a micro-frontend architecture. The method includes:

[0006] Registering the main application as a central message proxy component, wherein the central message proxy component is used to open a corresponding message communication interface for each sub-application;

[0007] Determine a message subscription request sent by a subscriber sub-application calling the message communication interface, and construct a relationship mapping between the subscriber sub-application and a message topic type carried in the message subscription request;

[0008] In response to a message publishing request sent by the message publisher sub-application calling the message communication interface, receiving a target topic message corresponding to the message publishing request;

[0009] According to the relationship mapping, the target topic message is broadcast to the corresponding subscriber sub-application.

[0010] In an optional implementation, for each sub-application in the micro-front-end architecture, based on the message receiving topic corresponding to the message acquisition requirement of the sub-application, the application programming interface corresponding to the central message agent component is called to register the sub-application as the subscriber sub-application corresponding to the message receiving topic.

[0011] In an optional implementation, for each sub-application in the micro-front-end architecture, based on the message publishing topic corresponding to the message publishing function of the sub-application, the application programming interface corresponding to the central message agent component is called to register the sub-application as the message publisher sub-application corresponding to the message publishing topic.

[0012] In an optional implementation manner, constructing a relationship mapping between the subscriber sub-application and the message subject carried in the message subscription request specifically includes:

[0013] In the central message proxy component, creating a mapping relationship object between the message topic type and the subscriber sub-application;

[0014] Parse the message subscription request to determine the target message topic type and the corresponding target subscriber sub-application carried therein;

[0015] Determining whether the relationship mapping corresponding to the target message topic type already exists in the central message proxy component;

[0016] If it exists, add the target subscriber sub-application to the corresponding subscriber list;

[0017] If not, create the relationship mapping corresponding to the target message topic type, and add the target subscriber sub-application to the corresponding subscriber list.

[0018] In an optional implementation, in response to the message publisher sub-application calling the message communication interface to send a message publishing request, after receiving the target topic message corresponding to the message publishing request, the method further includes:

[0019] The target topic message is stored in a preset message queue according to the corresponding message receiving order.

[0020] In an optional implementation manner, the process of receiving the target topic message and storing the target topic message in the preset message queue are performed asynchronously.

[0021] In an optional implementation, broadcasting the target topic message to the corresponding subscriber sub-application according to the relationship mapping specifically includes:

[0022] According to the order in which the messages are received, the target topic messages are sequentially retrieved from the preset message queue;

[0023] Filter the target relationship mapping that matches the message subject type with the target subject message, and determine the subscriber sub-application corresponding to the target relationship mapping;

[0024] Broadcast the target topic message to the corresponding subscriber sub-application.

[0025] The embodiment of the present disclosure also provides a micro-frontend message communication device based on a central message agent, which is applied to a main application in a micro-frontend architecture. The method includes:

[0026] A central message proxy component registration module, used to register the main application as a central message proxy component, wherein the central message proxy component is used to open a corresponding message communication interface for each sub-application;

[0027] A relationship mapping determination module, used to determine a message subscription request sent by a subscriber sub-application calling the message communication interface, and to construct a relationship mapping between the subscriber sub-application and a message subject type carried in the message subscription request;

[0028] A target topic message receiving module, configured to respond to a message publishing request sent by the message publisher sub-application calling the message communication interface, and receive a target topic message corresponding to the message publishing request;

[0029] A message broadcast module is used to broadcast the target topic message to the corresponding subscriber sub-application according to the relationship mapping.

[0030] An embodiment of the present disclosure also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the above-mentioned micro-front-end message communication method based on a central message agent, or steps in any possible implementation of the above-mentioned micro-front-end message communication method based on a central message agent is executed.

[0031] The present disclosure embodiment also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it executes the above-mentioned micro-front-end message communication method based on a central message agent, or the steps of any possible implementation of the above-mentioned micro-front-end message communication method based on a central message agent.

[0032] The disclosed embodiments also provide a computer program product, including a computer program / instructions, which, when executed by a processor, implement the above-mentioned micro-front-end message communication method based on a central message agent, or the steps in any possible implementation of the above-mentioned micro-front-end message communication method based on a central message agent.

[0033] The disclosed embodiment provides a micro-frontend message communication method and device based on a central message agent, which is applied to the main application in the micro-frontend architecture, registers the main application as a central message agent component, wherein the central message agent component is used to open a corresponding message communication interface for each sub-application; determines a message subscription request sent by a subscriber sub-application calling the message communication interface, and constructs a relationship mapping between the subscriber sub-application and the message topic type carried in the message subscription request; responds to a message publishing request sent by a message publisher sub-application calling the message communication interface, receives a target topic message corresponding to the message publishing request; broadcasts the target topic message to the corresponding subscriber sub-application according to the relationship mapping. Real-time message transmission between sub-applications can be achieved, communication efficiency can be improved, network overhead can be reduced, and a flexible message extension mechanism can be supported to meet various complex message communication requirements.

[0034] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0036] Figure 1 A flow chart of a micro-frontend message communication method based on a central message agent provided in an embodiment of the present disclosure is shown;

[0037] Figure 2 A flowchart of a method for determining a relationship mapping between a subscriber sub-application and a message topic type provided by an embodiment of the present disclosure is shown;

[0038] Figure 3A schematic diagram of a micro-frontend message communication device based on a central message agent provided by an embodiment of the present disclosure is shown;

[0039] Figure 4 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0040] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0041] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0042] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0043] According to research, in the micro-frontend architecture, sub-applications mainly use HTTP requests or WebSockets for message communication. This solution can realize message transmission between sub-applications, but the current message communication method will incur additional network overhead. Using HTTP requests or WebSockets for communication requires establishing and maintaining network connections, which increases additional network overhead and reduces communication efficiency. At the same time, since each communication needs to be transmitted through the network, the message transmission speed is affected by factors such as network delay and bandwidth, and data packet loss, data backlog, and data storms may occur, resulting in instability in the message transmission process. Furthermore, the existing solution is not flexible enough in supporting the precise delivery of messages, and cannot meet complex message communication requirements, resulting in the problem of limited precise message delivery. In addition, the existing solution may face some difficulties when expanding new sub-applications, requiring major changes and adjustments, and lacks scalability.

[0044] Based on the above research, the present disclosure provides a micro-frontend message communication method and device based on a central message agent, which is applied to the main application in the micro-frontend architecture, and the main application is registered as a central message agent component, wherein the central message agent component is used to open a corresponding message communication interface for each sub-application; determine the message subscription request sent by the subscriber sub-application calling the message communication interface, and construct a relationship mapping between the subscriber sub-application and the message topic type carried in the message subscription request; respond to the message publisher sub-application calling the message communication interface and send a message publishing request, receive the target topic message corresponding to the message publishing request; broadcast the target topic message to the corresponding subscriber sub-application according to the relationship mapping. Real-time message transmission between sub-applications can be achieved, communication efficiency can be improved, network overhead can be reduced, and a flexible message extension mechanism can be supported to meet various complex message communication needs.

[0045] To facilitate understanding of this embodiment, a micro-frontend message communication method based on a central message agent disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the micro-frontend message communication method based on a central message agent provided in the embodiment of the present disclosure is the micro-frontend message communication method based on a central message agent applied to the main application in the micro-frontend architecture. The micro-frontend architecture is a front-end architecture mode that divides the front-end application into multiple independent micro-frontends, each of which is responsible for one or more functions or pages. In the micro-frontend architecture, the main application is the entry point of the entire front-end application and is responsible for loading and managing all sub-applications. The main application usually provides basic layout, navigation and sharing functions, as well as routing management and communication mechanisms between sub-applications; the sub-application is an independent part of the main application, and each sub-application can be independently developed, deployed and maintained. The main application is responsible for loading and managing all sub-applications, and provides a mechanism to integrate and coordinate them to achieve a unified user experience. The main application and the sub-application can share data and state through mechanisms such as shared state and event communication, thereby realizing the combination and integration of front-end applications.

[0046] See also Figure 1 As shown, it is a flowchart of a micro-frontend message communication method based on a central message agent provided by an embodiment of the present disclosure, and the method includes steps S101 to S104, wherein:

[0047] S101. Register the main application as a central message proxy component, wherein the central message proxy component is used to open a corresponding message communication interface for each sub-application.

[0048] In the specific implementation, the main application in the micro-frontend architecture is first registered as a central message proxy component. The central message proxy component opens relevant message communication interfaces including publishing, registration, message subscription, etc. for sub-applications. The message communication interface can be an application programming interface (Application Programming Interface, API). The main application exposes relevant APIs to sub-applications by registering as a central message proxy component.

[0049] In this way, by introducing a central message proxy mechanism instead of forwarding micro-frontend messages to the backend, an efficient and flexible micro-frontend message communication mechanism is realized.

[0050] S102: Determine a message subscription request sent by a subscriber sub-application calling the message communication interface, and construct a relationship mapping between the subscriber sub-application and a message topic type carried in the message subscription request.

[0051] In the specific implementation, in the micro-frontend architecture, the sub-application calls the API corresponding to the main application as the central message proxy component to register as a message subscriber, and subscribes to the message topic of interest as a subscriber sub-application.

[0052] Here, the subscriber sub-application sends a message subscription request to the main application as the central message proxy component by calling the API interface corresponding to the central message proxy component, and establishes a relationship mapping between the message topic type carried in the message subscription request and the subscriber sub-application that sends the message subscription request.

[0053] Among them, for each sub-application in the micro-frontend architecture, according to the corresponding message receiving topic in the message acquisition requirement of the sub-application, the application programming interface corresponding to the central message agent component is called to register the sub-application as the subscriber sub-application corresponding to the message receiving topic.

[0054] For example, in the micro-frontend architecture, there are sub-applications 1, 2, 3, 4, 5, and 6, as well as topics A, B, and C. Among them, sub-application 4 has a message acquisition requirement for topics A and B, sub-application 5 has a message acquisition requirement for topics A and C, and sub-application 6 has a message acquisition requirement for topics B and C. Therefore, sub-applications 4, 5, and 6 are registered as subscriber sub-applications for topics A and B, A and C, and B and C, respectively.

[0055] As a possible implementation, see Figure 2 As shown, it is a flowchart of a method for determining a relationship mapping between a subscriber sub-application and a message topic type provided by an embodiment of the present disclosure, the method comprising steps S1021 to S1025, wherein:

[0056] S1021. In the central message proxy component, create a mapping relationship object between the message topic type and the subscriber sub-application.

[0057] S1022: Parse the message subscription request to determine the target message topic type and the corresponding target subscriber sub-application carried therein.

[0058] S1023: Determine whether the relationship mapping corresponding to the target message topic type already exists in the central message proxy component.

[0059] S1024. If so, add the target subscriber sub-application to the corresponding subscriber list.

[0060] S1025. If it does not exist, create the relationship mapping corresponding to the target message topic type, and add the target subscriber sub-application to the corresponding subscriber list.

[0061] In a specific implementation, the main application as a central message proxy component receives a message subscription request sent by a sub-application registered as a subscriber sub-application. After receiving the message subscription request from the subscriber sub-application, an empty message type and subscriber mapping relationship object is created in the central message proxy component.

[0062] Here, the mapping relationship object can be a JS object or a Map.

[0063] Furthermore, the central message proxy component parses the message subscription request of the subscriber sub-application, obtains the corresponding message type and subscriber information, and checks whether the mapping of the message type and the subscriber already exists in the mapping relationship object of the message type and the subscriber. If the mapping of the message type already exists in the central message proxy component, the subscriber is added to the corresponding subscriber list. If the mapping of the message type does not exist in the central message proxy component, a new mapping of the message type is created and the subscriber is added to the subscriber list of the mapping.

[0064] Afterwards, the central message broker component saves the updated mapping relationship object between the message type and the subscriber for use in subsequent message publishing.

[0065] S103: In response to the message publishing request sent by the message publisher sub-application calling the message communication interface, receiving a target topic message corresponding to the message publishing request.

[0066] In a specific implementation, a sub-application with message publishing capability calls an API corresponding to a main application as a central message proxy component to register as a message publisher sub-application, and publishes a target topic message corresponding to the message publishing capability.

[0067] Here, for each sub-application in the micro-frontend architecture, according to the message publishing topic corresponding to the message publishing function of the sub-application, the application programming interface corresponding to the central message proxy component is called to register the sub-application as the message publisher sub-application corresponding to the message publishing topic.

[0068] For example, in the micro-frontend architecture, there are sub-applications 1, 2, 3, 4, 5, and 6, as well as topics A, B, and C. Among them, sub-applications 1, 2, and 3 have the ability to publish messages for topics A, B, and C, respectively, and sub-applications 1, 2, and 3 are registered as message publisher sub-applications for topics A, B, and C, respectively.

[0069] Afterwards, the target topic message is stored in a preset message queue according to the corresponding message receiving order, wherein the process of receiving the target topic message and storing the target topic message in the preset message queue are performed asynchronously.

[0070] Exemplarily, a message queue component is implemented or introduced in the central message proxy component to receive and store messages A, B, and C published by the sub-application. After the previous message is processed, the central message proxy takes out the queue head message, filters it according to the subscription situation, and sends the message to the subscriber for message consumption.

[0071] Furthermore, the message storage process is designed as an asynchronous operation, that is, after the message publisher sub-application sends the message to the central message broker, it can return immediately, and then the central message broker will asynchronously store it in the message queue. This can reduce the waiting time of the message publisher sub-application and improve the response speed of the system.

[0072] Optionally, if the amount of messages in the system is large or different message types have obvious differences in importance, the messages in the message queue can be processed in partitions to improve the message processing capability and concurrency performance.

[0073] Thus, in order to improve performance, the central message broker uses message queues and other technical means to decouple messages and asynchronously communicate, enabling producers and consumers to work and expand independently, improving the system's responsiveness and scalability. At the same time, the buffering capacity of the message queue can balance the rate differences between publishers and subscribers, avoiding data loss and system downtime.

[0074] S104. Broadcast the target topic message to the corresponding subscriber sub-application according to the relationship mapping.

[0075] In the specific implementation, the message publishing and subscription mechanism is implemented through the central message broker component. When a message publisher sub-application publishes a message, the central message broker broadcasts the message to all subscriber sub-applications that subscribe to the topic.

[0076] As a possible implementation method, according to the order of message reception, the target topic messages are taken out in sequence from the preset message queue; the target relationship mapping that matches the message topic type and the target topic message is screened, and the subscriber sub-application corresponding to the target relationship mapping is determined; and the target topic message is broadcast to the corresponding subscriber sub-application.

[0077] Specifically, the central message proxy component takes messages from the message queue regularly in a first-in-first-out order by default, finds the subscriber sub-application according to the mapping relationship between the message type and the subscriber, and broadcasts the message to all subscriber sub-applications.

[0078] Optionally, for business scenarios with message queue partitions, you need to obtain messages based on the set partition priority and sorting rules to ensure that important messages are processed first.

[0079] Here, the subscriber sub-application can parse, process or update the UI after receiving the target topic message.

[0080] Exemplarily, the main application of the micro-frontend architecture performs central message proxying, sub-application 1 publishes message A, sub-applications 4 and 5 receive message A, but sub-application 6 does not receive it; sub-application 2 publishes message B, sub-applications 4 and 6 receive message B, but sub-application 5 does not receive it; sub-application 3 publishes message C, sub-applications 5 and 6 receive message C, but sub-application 4 does not receive it.

[0081] The embodiment of the present disclosure provides a micro-frontend message communication method based on a central message agent, which is applied to the main application in the micro-frontend architecture, and registers the main application as a central message agent component, wherein the central message agent component is used to open a corresponding message communication interface for each sub-application; determine the message subscription request sent by the subscriber sub-application calling the message communication interface, and construct a relationship mapping between the subscriber sub-application and the message topic type carried in the message subscription request; respond to the message publisher sub-application calling the message communication interface and send a message publishing request, receive the target topic message corresponding to the message publishing request; broadcast the target topic message to the corresponding subscriber sub-application according to the relationship mapping. Real-time message transmission between sub-applications can be achieved, communication efficiency can be improved, network overhead can be reduced, and a flexible message extension mechanism can be supported to meet various complex message communication needs.

[0082] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0083] Based on the same inventive concept, the embodiment of the present disclosure also provides a micro-front-end message communication device based on a central message agent corresponding to the micro-front-end message communication method based on a central message agent. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned micro-front-end message communication method based on a central message agent in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0084] See also Figure 3 , Figure 3 A schematic diagram of a micro-frontend message communication device based on a central message agent provided in an embodiment of the present disclosure. Figure 3 As shown in , the micro-frontend message communication device 300 based on the central message agent provided in the embodiment of the present disclosure is applied to the main application in the micro-frontend architecture, including:

[0085] The central message agent component registration module 310 is used to register the main application as a central message agent component, wherein the central message agent component is used to open a corresponding message communication interface for each sub-application.

[0086] The relationship mapping determination module 320 is used to determine the message subscription request sent by the subscriber sub-application calling the message communication interface, and to construct a relationship mapping between the subscriber sub-application and the message topic type carried in the message subscription request.

[0087] The target topic message receiving module 330 is used to respond to the message publishing request sent by the message publisher sub-application calling the message communication interface, and receive the target topic message corresponding to the message publishing request.

[0088] The message broadcast module 340 is used to broadcast the target topic message to the corresponding subscriber sub-application according to the relationship mapping.

[0089] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0090] The embodiment of the present disclosure provides a micro-frontend message communication device based on a central message agent, which is applied to the main application in the micro-frontend architecture, and registers the main application as a central message agent component, wherein the central message agent component is used to open a corresponding message communication interface for each sub-application; determine the message subscription request sent by the subscriber sub-application calling the message communication interface, and construct a relationship mapping between the subscriber sub-application and the message topic type carried in the message subscription request; respond to the message publisher sub-application calling the message communication interface and send a message publishing request, receive the target topic message corresponding to the message publishing request; broadcast the target topic message to the corresponding subscriber sub-application according to the relationship mapping. Real-time message transmission between sub-applications can be achieved, communication efficiency can be improved, network overhead can be reduced, and a flexible message extension mechanism can be supported to meet various complex message communication needs.

[0091] Corresponds to Figure 1 The micro-frontend message communication method based on the central message agent in the present disclosure embodiment also provides an electronic device 400, such as Figure 4 FIG. 4 is a schematic diagram of the structure of an electronic device 400 provided in an embodiment of the present disclosure, including:

[0092] Processor 41, memory 42, and bus 43; memory 42 is used to store execution instructions, including memory 421 and external memory 422; memory 421 here is also called internal memory, which is used to temporarily store operation data in processor 41 and data exchanged with external memory 422 such as hard disk. Processor 41 exchanges data with external memory 422 through memory 421. When the electronic device 400 is running, the processor 41 communicates with the memory 42 through bus 43, so that the processor 41 executes Figure 1 The steps of the micro-frontend message communication method based on the central message agent.

[0093] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the micro-frontend message communication method based on a central message agent described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0094] The presently disclosed embodiment also provides a computer program product, which includes computer instructions. When the computer instructions are executed by a processor, the steps of the micro-front-end message communication method based on the central message agent described in the above method embodiment can be executed. For details, please refer to the above method embodiment, which will not be repeated here.

[0095] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0096] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0097] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0098] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0099] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0100] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A micro-frontend message communication method based on a central message agent, characterized in that: Applied to the main application in the micro front-end architecture, the method includes: Registering the main application as a central message proxy component, wherein the central message proxy component is used to open a corresponding message communication interface for each sub-application; Determine a message subscription request sent by a subscriber sub-application calling the message communication interface, and construct a relationship mapping between the subscriber sub-application and a message topic type carried in the message subscription request; In response to a message publishing request sent by the message publisher sub-application calling the message communication interface, receiving a target topic message corresponding to the message publishing request; According to the relationship mapping, the target topic message is broadcast to the corresponding subscriber sub-application.

2. The method according to claim 1, characterized in that: For each sub-application in the micro-frontend architecture, according to the corresponding message receiving topic in the message acquisition requirement of the sub-application, the application programming interface corresponding to the central message proxy component is called to register the sub-application as the subscriber sub-application corresponding to the message receiving topic.

3. The method according to claim 1, characterized in that: For each sub-application in the micro-frontend architecture, according to the message publishing topic corresponding to the message publishing function of the sub-application, the application programming interface corresponding to the central message agent component is called to register the sub-application as the message publisher sub-application corresponding to the message publishing topic.

4. The method according to claim 1, characterized in that: Constructing a relationship mapping between the subscriber sub-application and the message subject carried in the message subscription request, specifically including: In the central message proxy component, creating a mapping relationship object between the message topic type and the subscriber sub-application; Parse the message subscription request to determine the target message topic type and the corresponding target subscriber sub-application carried therein; Determining whether the relationship mapping corresponding to the target message topic type already exists in the central message proxy component; If it exists, add the target subscriber sub-application to the corresponding subscriber list; If not, create the relationship mapping corresponding to the target message topic type, and add the target subscriber sub-application to the corresponding subscriber list.

5. The method according to claim 1, characterized in that In response to the message publisher sub-application calling the message communication interface to send the message publishing request, after receiving the target topic message corresponding to the message publishing request, the method further includes: The target topic message is stored in a preset message queue according to the corresponding message receiving order.

6. The method according to claim 5, characterized in that The process of receiving the target topic message and storing the target topic message in the preset message queue is performed asynchronously.

7. The method according to claim 5, characterized in that According to the relationship mapping, broadcasting the target topic message to the corresponding subscriber sub-application specifically includes: According to the order in which the messages are received, the target topic messages are sequentially retrieved from the preset message queue; Filter the target relationship mapping that matches the message subject type with the target subject message, and determine the subscriber sub-application corresponding to the target relationship mapping; Broadcast the target topic message to the corresponding subscriber sub-application.

8. A micro-frontend message communication device based on a central message agent, characterized in that: The main application used in the micro front-end architecture includes: A central message proxy component registration module, used to register the main application as a central message proxy component, wherein the central message proxy component is used to open a corresponding message communication interface for each sub-application; A relationship mapping determination module, used to determine a message subscription request sent by a subscriber sub-application calling the message communication interface, and to construct a relationship mapping between the subscriber sub-application and a message subject type carried in the message subscription request; A target topic message receiving module, configured to respond to a message publishing request sent by the message publisher sub-application calling the message communication interface, and receive a target topic message corresponding to the message publishing request; A message broadcast module is used to broadcast the target topic message to the corresponding subscriber sub-application according to the relationship mapping.

9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate through the bus. When the machine-readable instructions are executed by the processor, the steps of the micro-front-end message communication method based on a central message agent are performed as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the micro-frontend message communication method based on a central message agent as described in any one of claims 1 to 7.