Message processing method, device and computer readable storage medium

By building business modules and target components separately, the independence between the two is achieved, and the problem of low information interaction between the business modules and the server in the existing technology is solved, and interaction stability and maintainability are improved.

CN115834657BActive Publication Date: 2025-05-02HILLSTONE NETWORKS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211482397.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-24
Publication Date
2025-05-02
Estimated Expiration
2042-11-24

AI Technical Summary

Technical Problem

In the prior art, the information interaction between the business module and the server is inefficient, and the difficulty of maintaining global components continues to increase, resulting in unstable interactions.

Method used

By building the business module and the target component separately, the two are independent. The business module is only responsible for processing business information, and the target component is only responsible for establishing data communication connections between the client and the server.

Benefits of technology

It improves the interaction stability and information interaction efficiency between the business module and the target component, reduces the difficulty of code maintenance, and enhances the maintainability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115834657B_ABST
    Figure CN115834657B_ABST
Patent Text Reader

Abstract

The present application discloses a message processing method, device and computer-readable storage medium. The method includes: obtaining a message subscription request initiated by a target business module in a client, wherein the target business module is any one of a plurality of business modules, and the business module is composed of a first code; calling a message subscription function encapsulated in a target component according to the message subscription request, wherein the target component is used to establish a data communication connection between the client and the server, and the target component is composed of a second code, and the first code and the second code are independent of each other; sending a message subscription request to the server based on the message subscription function; receiving target information returned by the server based on the message subscription request, and rendering the functional components in the target business module according to the target information. The present application solves the technical problem of low efficiency of information interaction between the client's business module and the server in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information processing technology, and in particular to a message processing method, device and computer-readable storage medium. Background Art

[0002] WebSocket is a protocol for full-duplex communication over a single TCP (transmission control protocol) connection. WebSocket makes data exchange between the front-end and the back-end much simpler, allowing the back-end to actively push data to the front-end, that is, the data can be pushed to the front-end in a timely manner after the back-end detects data changes. By building a component responsible for communication transmission through WebSocket, the front-end and the back-end only need to establish a connection once to perform persistent two-way data transmission.

[0003] In the prior art, the codes related to business modules such as message subscription and page rendering are integrated with the codes related to the WebSocket component responsible for establishing data communication connections to generate a global component, so that every business developer has to modify the entire global component when adding or modifying a business module. As the demand for modifying business modules increases, the global component becomes larger and larger, which leads to the increasing difficulty of maintaining the global component, and the interaction between the business module and the server becomes more and more unstable, which in turn causes the problem of decreasing efficiency of information interaction between the business module and the server.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present application provide a message processing method, device and computer-readable storage medium to at least solve the technical problem of low efficiency of information interaction between the business module of the client and the server in the prior art.

[0006] According to one aspect of an embodiment of the present application, a message processing method is provided, including: obtaining a message subscription request initiated by a target business module in a client, wherein the target business module is any one of a plurality of business modules, each business module is used to process business information of a business type, and the business module is composed of a first code; calling a message subscription function encapsulated in a target component according to the message subscription request, wherein the target component is used to establish a data communication connection between the client and the server, the target component is composed of a second code, and the first code and the second code are independent of each other; sending the message subscription request to the server based on the message subscription function; receiving target information returned by the server based on the message subscription request, and rendering the functional components in the target business module according to the target information.

[0007] Furthermore, the message processing method also includes: before obtaining the message subscription request initiated by the target business module in the client, sending heartbeat information to the server at every preset time interval, wherein the heartbeat information at least includes verification information, and the verification information is used to represent the identity information of the login object of the client; detecting the connection status of the data communication connection according to the heartbeat information; when the connection status is a first state, obtaining the message subscription request initiated by the target business module, wherein the first state represents that the data communication connection is in a normal connection state.

[0008] Furthermore, the message processing method also includes: obtaining login information on the client, wherein the login information includes at least the account information and password information of the login object; receiving the verification result after the server verifies the login information according to a preset list, wherein the preset list is used to record the account information and password information with client login authority; when the login information verification is successful, obtaining the verification information generated by the server according to the login information; establishing a data communication connection with the server through the target component; generating heartbeat information according to the verification information, and sending the heartbeat information to the server at every preset time interval.

[0009] Furthermore, the message processing method also includes: detecting whether the server returns reply information corresponding to the heartbeat information within the target time length; when the server returns the reply information within the target time length, determining that the connection state is a first state; when the server does not return the reply information within the target time length, determining that the connection state is a second state, wherein the second state indicates that the data communication connection is in an abnormal connection state.

[0010] Furthermore, the message processing method also includes: after determining that the connection state is the second state, re-establishing the data communication connection with the server through the target component, and detecting whether the connection state of the re-established data communication connection is the first state; when it is detected that the connection state of the re-established data communication connection is the first state, determining that the data communication connection between the client and the server is successfully established; when it is detected that the connection state of the re-established data communication connection is the second state, determining that the data communication connection between the client and the server has failed to be established; counting the number of times the statistical data communication connection fails to be established, and when the number is greater than a preset threshold, prohibiting the re-establishment of the data communication connection.

[0011] Furthermore, the message processing method also includes: sending a message subscription request to a first subcomponent in the target component, wherein the first subcomponent is used to establish a data transmission channel between the business module and the target component; and sending the message subscription function to the target business module through the first subcomponent.

[0012] Furthermore, the message processing method also includes: when multiple business modules initiate consumption subscription requests at the same time, sending the message subscription function to the multiple business modules in parallel through the first subcomponent.

[0013] According to another aspect of an embodiment of the present application, a message processing device is also provided, including: an acquisition module, used to obtain a message subscription request initiated by a target business module in a client, wherein the target business module is any one of a plurality of business modules, each business module is used to process business information of a business type, and the business module is composed of a first code; a calling module, used to call a message subscription function encapsulated in a target component according to a message subscription request, wherein the target component is used to establish a data communication connection between the client and the server, the target component is composed of a second code, and the first code and the second code are independent of each other; a sending module, used to send a message subscription request to a server based on the message subscription function; a receiving module, used to receive target information returned by the server based on the message subscription request, and render the functional components in the target business module according to the target information.

[0014] According to another aspect of an embodiment of the present application, a computer-readable storage medium is further provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned message processing method when running.

[0015] According to another aspect of an embodiment of the present application, an electronic device is also provided, which includes one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors are implemented to run the programs, wherein the programs are configured to execute the above-mentioned message processing method when running.

[0016] In this application, the business module and target component are constructed separately. After obtaining the message subscription request initiated by the target business module in the client, the message subscription function encapsulated in the target component is called according to the message subscription request, and the message subscription request is sent to the server based on the message subscription function. Finally, the target information returned by the server based on the message subscription request is received, and the functional components in the target business module are rendered according to the target information. Among them, the target business module is any one of the multiple business modules, each business module is used to process the business information of a business type, and the business module is composed of a first code; the target component is used to establish a data communication connection between the client and the server, and the target component is composed of a second code, and the first code and the second code are independent of each other.

[0017] From the above content, it can be seen that the present application achieves the purpose of independence between the target component and the business module by separately constructing the business module and the target component. Since the corresponding codes of the two are completely decoupled, the business module does not need to pay attention to the data communication connection, but only needs to be responsible for processing the corresponding business information. The target component also does not need to pay attention to which messages the business module needs to subscribe to, but only needs to be responsible for establishing the data communication connection between the client and the server. The target component and the business module each have their own responsibilities, which not only improves the maintainability of the target component and the business module, but also improves the interaction stability between the business module and the target component, and improves the information interaction efficiency between the business module and the server.

[0018] It can be seen that the technical solution of the present application achieves the purpose of decoupling and separating the code of the target component from the code of the business module, thereby achieving the technical effect of improving the maintainability of the code, and further solving the technical problem of low efficiency of information interaction between the client's business module and the server in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0020] Figure 1 is a schematic diagram of an optional message processing method according to an embodiment of the present application;

[0021] Figure 2 is a schematic diagram of an optional front-end page structure according to an embodiment of the present application;

[0022] Figure 3 is a functional schematic diagram of an optional target component according to an embodiment of the present application;

[0023] Figure 4 is a functional schematic diagram of a service module according to an embodiment of the present application;

[0024] Figure 5 is a schematic diagram of the relationship between a target component and a business module according to an embodiment of the present application;

[0025] Figure 6 It is a schematic diagram of an optional message processing device according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] Example 1

[0029] According to an embodiment of the present application, an embodiment of a message processing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0030] Figure 1 is a schematic diagram of an optional message processing method according to an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:

[0031] Step S101: obtaining a message subscription request initiated by a target service module in a client.

[0032] In step S101, the target business module is any one of a plurality of business modules, each business module is used to process business information of a business type, and the business module is composed of a first code.

[0033] Specifically, the client includes but is not limited to terminal devices such as smart phones, smart tablets, desktop computers, and laptops. Among them, there are multiple business modules in the front-end page of the client for displaying the business information returned by the server, and different business modules process business information of different business types. For example, the user sends a virus detection task to the back-end (i.e., the server) through the front-end page. It takes a while for the back-end to execute the virus detection task. During this process, the business module A of the front-end page needs to display the execution status of the back-end virus detection task in real time. Or, the user clicks to upgrade a system service through the front-end page. It takes a certain amount of time for the back-end to upgrade this system service. During this process, the business module B of the front-end page needs to display various states of the execution upgrade process in real time. Or, the user configures a task that needs to alert the user after the CPU usage exceeds 90% through the front-end page. After the back-end detects that the CPU usage exceeds 90%, it can directly push data to the business module C of the front-end page for real-time alarm.

[0034] The above-mentioned message subscription request is a request for the target business module to request the server to obtain the corresponding business information. For example, assuming that the target business module is the above-mentioned business module A, the corresponding message subscription request is to request the server to return the execution status of the virus killing task to business module A.

[0035] In addition, in an optional embodiment, the above-mentioned client is the execution subject of the message processing method in this application. Each business module is composed of a first code.

[0036] Step S102: calling the message subscription function encapsulated in the target component according to the message subscription request.

[0037] In step S102, the target component is used to establish a data communication connection between the client and the server, and the target component is composed of a second code, and the first code and the second code are independent of each other.

[0038] It should be noted that, currently in WEB applications, the interaction between the front-end page and the back-end is generally carried out in the form of HTTP (Hyper Text Transfer Protocol). The specific implementation method of the HTTP protocol is a one-way interaction method in which the front-end page initiates a request and the back-end responds. When the back-end executes a task, it often takes a long time. At this time, if the WEB application wants to perceive the status of the task in real time, the traditional solution is to use HTTP polling, that is, the client sends an HTTP request to the server at regular intervals to obtain the status of the current task. This method will still send requests when the status of the back-end task has not changed, increasing network overhead and occupying too many unnecessary server resources. There will also be a problem that after the status of the back-end task has changed, the front-end does not send an HTTP request in time, resulting in poor real-time display of the execution status of the back-end task on the front-end. With the development of WEB application technology, the WebSocket protocol came into being.

[0039] WebSocket is a protocol for full-duplex communication over a single TCP connection. WebSocket makes data exchange between the front-end page and the back-end much simpler, allowing the back-end to actively push data to the front-end page, that is, the data can be pushed to the front-end page in a timely manner after the back-end detects data changes. In the implementation of WebSocket, the front-end page and the back-end only need to establish a connection once to achieve persistent two-way data transmission. Through WebSocket transmission, the data format is relatively lightweight, the performance overhead is small, and the communication is efficient.

[0040] However, in existing WebSocket implementation schemes, the subscription messages of each business module are usually placed in the callback of a successful WebSocket connection. Such an implementation scheme will cause the business module code to be coupled with the WebSocket component code, making the code lengthy and confusing, greatly increasing the workload of code maintenance and the probability of code errors.

[0041] The following is an example of a WebSocket implementation code in the prior art:

[0042]

[0043] According to the solution of the prior art, the WebSocket component and each business module are actually integrated into a global component, which contains both the processing logic code of how each business module subscribes to messages and the processing logic code of how to establish a data communication connection between the front-end page and the back-end according to the WebSocket protocol. It is easy to notice that since the codes related to multiple business modules are integrated with the codes related to the WebSocket component responsible for establishing the data communication connection, as time goes by, the demand for business modules increases, and the global component will become larger and larger. If the comments are not clear enough, or the business modules are constantly changing, the global component will become more and more difficult to maintain, which greatly increases the workload of code maintenance and is prone to code errors, which in turn affects the interaction stability between the front-end page and the server.

[0044] In order to solve the above-mentioned problems, the present application decouples the construction of the business module from the construction of the target component. Among them, the target component can be understood as a WebSocket component that is only responsible for establishing a data communication connection between the client and the server. Unlike the business module, which is composed of a first code, the target component is composed of a second code. The first code and the second code are independent of each other and will be maintained independently of each other during code maintenance. The two codes are completely decoupled, which not only increases the clarity of the overall code, but also improves the maintainability of the code. When the code of any business module is modified later, the technicians do not have to worry about affecting the normal use of the target component, thereby improving the interaction stability between the front-end page and the back-end.

[0045] In addition, in order to ensure that the message subscription request of each business module can be transmitted to the server through the data communication connection established by the target component, a message subscription function will be encapsulated in the target component, and the message subscription function will be exposed to all business modules. In other words, each business module can access and call the message subscription function.

[0046] like Figure 2 As shown, Figure 2 A schematic diagram of the structure of an optional front-end page according to an embodiment of the present application is shown. Figure 2 In the example, a WebSocket component (ie, a target component), a business module 1, and a business module 2 are included. The message subscription function encapsulated in the WebSocket component is exposed to the business module 1 and the business module 2.

[0047] Step S103: Send a message subscription request to the server based on the message subscription function.

[0048] In step S103, the client can send the message subscription request initiated by the target business module to the server according to the message subscription function. Figure 2 In the example, if business module 1 initiates a message subscription request 1, the client can send the message subscription request 1 to the server by calling the message subscription function.

[0049] Step S104, receiving target information returned by the server based on the message subscription request, and rendering the functional components in the target business module according to the target information.

[0050] In step S104, the server will return the target information requested by the target business module to the target business module according to the message subscription request. After receiving the target information, the client will render the functional components in the target business module, and when the functional component rendering is completed, the rendered functional components will be displayed in the client.

[0051] Based on the contents of the above steps S101 to S104, it can be known that in this application, the business module and the target component are constructed separately. After obtaining the message subscription request initiated by the target business module in the client, the message subscription function encapsulated in the target component is called according to the message subscription request, and the message subscription request is sent to the server based on the message subscription function. Finally, the target information returned by the server based on the message subscription request is received, and the functional components in the target business module are rendered according to the target information. Among them, the target business module is any one of the multiple business modules, each business module is used to process the business information of a business type, and the business module is composed of a first code; the target component is used to establish a data communication connection between the client and the server, and the target component is composed of a second code, and the first code and the second code are independent of each other.

[0052] From the above content, it can be seen that the present application achieves the purpose of independence between the target component and the business module by separately constructing the business module and the target component. Since the corresponding codes of the two are completely decoupled, the business module does not need to pay attention to the data communication connection, but only needs to be responsible for processing the corresponding business information. The target component also does not need to pay attention to which messages the business module needs to subscribe to, but only needs to be responsible for establishing the data communication connection between the client and the server. The target component and the business module each have their own responsibilities, which not only improves the maintainability of the target component and the business module, but also improves the interaction stability between the business module and the target component, and improves the information interaction efficiency between the business module and the server.

[0053] It can be seen that the technical solution of the present application achieves the purpose of decoupling and separating the code of the target component from the code of the business module, thereby achieving the technical effect of improving the maintainability of the code, and further solving the technical problem of low efficiency of information interaction between the client's business module and the server in the prior art.

[0054] In an optional embodiment, before obtaining a message subscription request initiated by a target business module in a client, the client sends a heartbeat message to the server at a preset interval, wherein the heartbeat message contains at least verification information, and the verification information is used to represent the identity information of the login object of the client. Then, the client detects the connection state of the data communication connection according to the heartbeat information, and obtains the message subscription request initiated by the target business module when the connection state is a first state, wherein the first state represents that the data communication connection is in a normal connection state.

[0055] Optionally, in order to generate heartbeat information, the client first obtains login information on the client, wherein the login information at least includes the account information and password information of the login object. Then, the client receives the verification result after the server verifies the login information according to a preset list, wherein the preset list is used to record the account information and password information with the client login authority. If the login information verification is successful, the client obtains the verification information generated by the server according to the login information, and establishes a data communication connection with the server through the target component. Finally, the client generates heartbeat information based on the verification information, and sends the heartbeat information to the server at intervals of a preset duration.

[0056] Specifically, Figure 3 A functional schematic diagram of a target component is shown, wherein Figure 3 As shown, after the user enters the account and password on the front-end page and logs in successfully, the front-end page establishes a WebSocket connection (i.e., a data communication connection) with the server through the target component, and then the front-end page sends a heartbeat message to the server once every preset time interval, wherein the heartbeat message contains at least a verification information token. If the verification information token is invalid, the server will not return a reply message to the front-end page for the heartbeat message and will close the WebSocket connection.

[0057] It should be noted that only after the login information is successfully verified, the front-end page will establish a unique WebSocket connection with the server, and the connection contains the verification information token obtained after the login is successful, which is used for server-side authentication. If the login fails, no connection is established. This processing method ensures the security of data transmission and avoids data leakage.

[0058] In addition, it should be noted that in the WebSocket protocol, if the WebSocket connection channel between the front-end page and the server is idle for a long time, that is, when there is no traffic transmission, the WebSocket connection between the front-end page and the server will be automatically closed. In order to avoid this situation, this application sends heartbeat information at preset intervals to ensure that the front-end page and the server will not be idle for a long time, thereby ensuring that the WebSocket connection will not be closed suddenly.

[0059] In an optional embodiment, the client will also detect whether the server returns reply information corresponding to the heartbeat information within the target time length, and when the server returns the reply information within the target time length, it determines that the connection state is the first state; when the server does not return the reply information within the target time length, it determines that the connection state is the second state, wherein the second state indicates that the data communication connection is in an abnormal connection state.

[0060] Optionally, the above target duration can be customized. If the server can normally receive the heartbeat information sent by the client and determines that the verification information in the heartbeat information is correct, the server will return a reply message to the client within the target duration. After the client receives the reply message, the client will determine that the data communication connection currently established with the server is in a normal connection state. If the client does not receive the reply message returned by the server within the target duration, the client will determine that the data communication connection currently established with the server is in an abnormal connection state.

[0061] It should be noted that there may be many reasons why the client does not receive the reply information returned by the server within the target time. For example, the verification information in the heartbeat message is invalid, resulting in the server not generating a reply message at all; or, due to a failure on the server, the server does not receive the heartbeat message or cannot send a reply message; or, due to an unstable network between the server and the client, the transmission time of the heartbeat message and the reply message is too long.

[0062] From the above content, it can be seen that the present application provides a method for self-diagnosis of the data communication connection status. Only when the data communication connection is in a normal connection state will the client initiate a message subscription to the server, thereby ensuring the stability of the information interaction between the client and the server.

[0063] In an optional embodiment, after determining that the connection state is the second state, the client re-establishes the data communication connection with the server through the target component, and detects whether the connection state of the re-established data communication connection is the first state. In the case where it is detected that the connection state of the re-established data communication connection is the first state, the client determines that the data communication connection between the client and the server is successfully established, and in the case where it is detected that the connection state of the re-established data communication connection is the second state, the client determines that the data communication connection between the client and the server fails to be established. Finally, the client counts the number of times the statistical data communication connection fails to be established, and prohibits re-establishing the data communication connection if the number is greater than a preset threshold.

[0064] Optional, such as Figure 3 As shown, the client is configured with a strategy for automatic reconnection after WebSocket connection is disconnected, and when the number of automatic reconnections exceeds a preset threshold, automatic reconnection is stopped. Specifically, by configuring a strategy for automatic reconnection after WebSocket connection is disconnected and the number of reconnections has a maximum upper limit, the problem of unlimited reconnection between the front-end page and the server can be avoided, thereby saving server resources.

[0065] It should be noted that if Figure 3 As shown in the figure, before the client initiates a message subscription request to the server through the message subscription function, it will first determine the status of the current WebSocket connection. If the connection is disconnected, it will set automatic reconnection again, and wait for the reconnection to succeed before initiating a subscription message to the backend. This ensures that when the network is temporarily interrupted, as long as the number of automatic reconnections of the WebSocket connection does not exceed the preset threshold, the WebSocket connection can be reestablished after the network is restored, and will not affect the normal use of the business module. It should also be noted that when the business module determines whether a message subscription is currently required, it also needs to communicate with the server through the HTTP protocol. If normal communication is possible, it means that the network has returned to normal. At this time, the WebSocket connection can be reestablished when subscribing to the message, and it can be successfully established normally. When the WebSocket reconnects successfully, the client will reset the number of consecutive failures to establish a connection.

[0066] In an optional embodiment, the client sends a message subscription request to a first subcomponent in the target component, wherein the first subcomponent is used to establish a data transmission channel between the business module and the target component. Then, the client sends a message subscription function to the target business module through the first subcomponent.

[0067] Optional, such as Figure 3As shown, the WebSocket component uses React's Context to expose the encapsulated message subscription function to the business module. React is a JavaScript library for building front-end pages, and Context is a context mechanism. Specifically, the purpose of Context design is to share data that is "global" for a component tree. Context allows this data to be "broadcasted" to all components under the component tree, and all components can access this data and subsequent data updates. In addition, each Context object returns a ProviderReact component (i.e., the first subcomponent mentioned above), which allows the consumer component (i.e., the business module) to subscribe to changes in Context. The first subcomponent receives a value attribute and passes it to the consumer component. A first subcomponent can have a corresponding relationship with multiple consumer components. In the specific implementation process, the WebSocket component calls React's createContext to create a context environment, i.e., a Context object. Then, the WebSocket component deconstructs the Provider React component from the Context object, sets the value to the encapsulated message subscription function, and uses each business module as its subcomponent, i.e., the consumer component.

[0068] From the above content, it can be seen that in this application, the WebSocket component uses the context mechanism of react to expose the encapsulated message subscription function to each business module. Each business module reads the message subscription function from the context of react, and then initiates a message subscription request related to its own module according to its own needs, thereby achieving the purpose of rendering the functional components related to its own module.

[0069] In addition, when multiple business modules initiate consumption subscription requests at the same time, the client sends the message subscription function to the multiple business modules in parallel through the first subcomponent.

[0070] Optionally, in the prior art, if multiple business modules initiate consumption subscription requests at the same time, each business module needs to establish a WebSocket connection with the server, which will lead to the problem of too many WebSocket connections corresponding to the server, increasing the resource overhead of the server. In the present application, each business module will not create its own WebSocket connection, and multiple business modules will obtain the message subscription function encapsulated in the WebSocket component through the first subcomponent, and the WebSocket component will only establish a WebSocket connection with the server. Therefore, in the present application, the server does not need to spend too much resources to maintain multiple WebSocket connections, thereby achieving the effect of reducing the resource overhead of the server.

[0071] In an optional embodiment, Figure 4 A functional schematic diagram of a service module according to an embodiment of the present application is shown, such as Figure 4 As shown in the figure, no matter it is business module 1 or business module 2, each business module does not need to pay attention to the information related to the WebSocket connection, such as establishing a WebSocket connection, sending heartbeat information, authentication, WebSocket connection disconnection and reconnection, and other operation information. A WebSocket component can be used by multiple business modules in the entire front-end page. In addition, each business module can obtain the message subscription function exposed by the WebSocket component through the context mechanism. At the same time, each business module initiates a message subscription request related to its own module according to its own needs, and after receiving the business information returned by the server, it renders the corresponding functional component according to the business information. Finally, when the business module determines that there is no new data change, the business module cancels the message subscription according to the instance returned by the message subscription function, that is, sends a message subscription cancellation request to the server.

[0072] in addition, Figure 5 FIG. 1 shows a schematic diagram of the relationship between a target component and a service module according to an embodiment of the present application. Figure 5 As shown in the figure, the WebSocket component is the producer of Context, and each business module is the consumer of Context. The WebSocket component implements operations such as establishing WebSocket connection, sending heartbeat information, authentication, WebSocket connection disconnection and reconnection, etc. Each business module only needs to focus on its own business. At the same time, the WebSocket component provides a message subscription function containing the WebSocket connection channel to each business module. Each business module initiates a message subscription request when needed and renders the functional component according to the business information returned by the server.

[0073] The following is a code example based on constructing the target component, business module 1, and business module 2:

[0074] WebSocket Components:

[0075] exportconst wsContext=createContext({subscribe:{}});

[0076] const{Provider}=wsContext;

[0077] WebSocket connection related

[0078] Message subscription function subscribe

[0079] / / children is a Web-based consumer component that contains a business module

[0080] return<Provider value={{subscribe}}> {children};

[0081] Business Module 1:

[0082]

[0083] Business Module 2:

[0084]

[0085]

[0086] From the above content, it can be seen that the present application achieves the purpose of independence between the target component and the business module by separately constructing the business module and the target component. Since the corresponding codes of the two are completely decoupled, the business module does not need to pay attention to the data communication connection, but only needs to be responsible for processing the corresponding business information. The target component also does not need to pay attention to which messages the business module needs to subscribe to, but only needs to be responsible for establishing the data communication connection between the client and the server. The target component and the business module each have their own responsibilities, which not only improves the maintainability of the target component and the business module, but also improves the interaction stability between the business module and the target component, and improves the information interaction efficiency between the business module and the server.

[0087] Example 2

[0088] According to an embodiment of the present application, an embodiment of a message processing device is also provided, such as Figure 6 As shown, the device includes: an acquisition module 601, used to obtain a message subscription request initiated by a target business module in the client, wherein the target business module is any one of a plurality of business modules, each business module is used to process business information of a business type, and the business module is composed of a first code; a calling module 602, used to call a message subscription function encapsulated in a target component according to the message subscription request, wherein the target component is used to establish a data communication connection between the client and the server, the target component is composed of a second code, and the first code and the second code are independent of each other; a sending module 603, used to send a message subscription request to the server based on the message subscription function; a receiving module 604, used to receive target information returned by the server based on the message subscription request, and render the functional components in the target business module according to the target information.

[0089] Specifically, the client includes but is not limited to terminal devices such as smart phones, smart tablets, desktop computers, and laptops. Among them, there are multiple business modules in the front-end page of the client for displaying the business information returned by the server, and different business modules process business information of different business types. For example, the user sends a virus detection task to the back-end (i.e., the server) through the front-end page. It takes a while for the back-end to execute the virus detection task. During this process, the business module A of the front-end page needs to display the execution status of the back-end virus detection task in real time. Or, the user clicks to upgrade a system service through the front-end page. It takes a certain amount of time for the back-end to upgrade this system service. During this process, the business module B of the front-end page needs to display various states of the execution upgrade process in real time. Or, the user configures a task that needs to alert the user after the CPU usage exceeds 90% through the front-end page. After the back-end detects that the CPU usage exceeds 90%, it can directly push data to the business module C of the front-end page for real-time alarm.

[0090] The above-mentioned message subscription request is a request for the target business module to request the server to obtain the corresponding business information. For example, assuming that the target business module is the above-mentioned business module A, the corresponding message subscription request is to request the server to return the execution status of the virus killing task to business module A.

[0091] In addition, in an optional embodiment, the message processing device in this embodiment may be arranged in the client, so that the client serves as the execution subject of the message processing method in the present application.

[0092] It should be noted that, currently in WEB applications, the interaction between the front-end page and the back-end is generally carried out in the form of HTTP (Hyper Text Transfer Protocol). The specific implementation method of the HTTP protocol is a one-way interaction method in which the front-end page initiates a request and the back-end responds. When the back-end executes a task, it often takes a long time. At this time, if the WEB application wants to perceive the status of the task in real time, the traditional solution is to use HTTP polling, that is, the client sends an HTTP request to the server at regular intervals to obtain the status of the current task. This method will still send requests when the status of the back-end task has not changed, increasing network overhead and occupying too many unnecessary server resources. There will also be a problem that after the status of the back-end task has changed, the front-end does not send an HTTP request in time, resulting in poor real-time display of the execution status of the back-end task on the front-end. With the development of WEB application technology, the WebSocket protocol came into being.

[0093] WebSocket is a protocol for full-duplex communication over a single TCP connection. WebSocket makes data exchange between the front-end page and the back-end much simpler, allowing the back-end to actively push data to the front-end page, that is, the data can be pushed to the front-end page in a timely manner after the back-end detects data changes. In the implementation of WebSocket, the front-end page and the back-end only need to establish a connection once to achieve persistent two-way data transmission. Through WebSocket transmission, the data format is relatively lightweight, the performance overhead is small, and the communication is efficient.

[0094] However, in existing WebSocket implementation schemes, the subscription messages of each business module are usually placed in the callback of a successful WebSocket connection. Such an implementation scheme will cause the business module code to be coupled with the WebSocket component code, making the code lengthy and confusing, greatly increasing the workload of code maintenance and the probability of code errors.

[0095] The following is a code example snippet of a WebSocket implementation scheme in the prior art:

[0096]

[0097]

[0098] According to the solution of the prior art, the WebSocket component and each business module are actually integrated into a global component, which contains both the processing logic code of how each business module subscribes to messages and the processing logic code of how to establish a data communication connection between the front-end page and the back-end according to the WebSocket protocol. It is easy to notice that since the codes related to multiple business modules are integrated with the codes related to the WebSocket component responsible for establishing the data communication connection, as time goes by, the demand for business modules increases, and the global component will become larger and larger. If the comments are not clear enough, or the business modules are constantly changing, the global component will become more and more difficult to maintain, which greatly increases the workload of code maintenance and is prone to code errors, which in turn affects the interaction stability between the front-end page and the server.

[0099] In order to solve the above-mentioned problems, the present application decouples the construction of the business module from the construction of the target component. Among them, the target component can be understood as a WebSocket component that is only responsible for establishing a data communication connection between the client and the server. Unlike the business module composed of the first code, the target component is composed of the second code. The first code and the second code are independent of each other and will be maintained independently of each other during code maintenance. The two codes are completely decoupled, which not only increases the clarity of the overall code, but also improves the maintainability of the code. When the code of any business module is modified later, the technicians do not have to worry about affecting the normal use of the target component, thereby improving the interaction stability between the front-end page and the back end.

[0100] In addition, in order to ensure that the message subscription request of each business module can be transmitted to the server through the data communication connection established by the target component, a message subscription function will be encapsulated in the target component, and the message subscription function will be exposed to all business modules. In other words, each business module can access and call the message subscription function.

[0101] like Figure 2 As shown, Figure 2 A schematic diagram of the structure of an optional front-end page according to an embodiment of the present application is shown. Figure 2 In the example, a WebSocket component (ie, a target component), a business module 1, and a business module 2 are included. The message subscription function encapsulated in the WebSocket component is exposed to the business module 1 and the business module 2.

[0102] From the above content, it can be seen that the present application achieves the purpose of independence between the target component and the business module by separately constructing the business module and the target component. Since the corresponding codes of the two are completely decoupled, the business module does not need to pay attention to the data communication connection, but only needs to be responsible for processing the corresponding business information. The target component also does not need to pay attention to which messages the business module needs to subscribe to, but only needs to be responsible for establishing the data communication connection between the client and the server. The target component and the business module each have their own responsibilities, which not only improves the maintainability of the target component and the business module, but also improves the interaction stability between the business module and the target component, and improves the information interaction efficiency between the business module and the server.

[0103] It can be seen that the technical solution of the present application achieves the purpose of decoupling and separating the code of the target component from the code of the business module, thereby achieving the technical effect of improving the maintainability of the code, and further solving the technical problem of low efficiency of information interaction between the client's business module and the server in the prior art.

[0104] Optionally, the message processing device further includes: a first sending module, a first detection module and a first acquisition module. The first sending module is used to send heartbeat information to the server at a preset interval, wherein the heartbeat information at least includes verification information, and the verification information is used to represent the identity information of the login object of the login client; the first detection module is used to detect the connection status of the data communication connection according to the heartbeat information; the first acquisition module is used to obtain the message subscription request initiated by the target business module when the connection status is the first status, wherein the first status represents that the data communication connection is in a normal connection status.

[0105] Optionally, the first sending module further includes: a first acquisition unit, a verification unit, a generation unit and a first sending unit. The first acquisition unit is used to acquire the login information on the client, wherein the login information at least includes the account information and password information of the login object; the verification unit is used to verify the login information according to a preset list to obtain a verification result, wherein the preset list is used to record the account information and password information with the client login authority; the generation unit is used to establish a data communication connection with the server through the target component when the login information is successfully verified, and generate verification information according to the login information; the first sending unit is used to generate heartbeat information according to the verification information, and send the heartbeat information to the server at every preset time interval.

[0106] Optionally, in order to generate heartbeat information, the client first obtains login information on the client, wherein the login information at least includes the account information and password information of the login object. Then, the client receives the verification result after the server verifies the login information according to a preset list, wherein the preset list is used to record the account information and password information with the client login authority. If the login information verification is successful, the client obtains the verification information generated by the server according to the login information, and establishes a data communication connection with the server through the target component. Finally, the client generates heartbeat information based on the verification information, and sends the heartbeat information to the server at intervals of a preset duration.

[0107] Specifically, Figure 3 A functional schematic diagram of a target component is shown, wherein Figure 3 As shown, after the user enters the account and password on the front-end page and logs in successfully, the front-end page establishes a WebSocket connection (i.e., a data communication connection) with the server through the target component, and then the front-end page sends a heartbeat message to the server once every preset time interval, wherein the heartbeat message contains at least a verification information token. If the verification information token is invalid, the server will not return a reply message to the front-end page for the heartbeat message and will close the WebSocket connection.

[0108] It should be noted that only after the login information is successfully verified, the front-end page will establish a unique WebSocket connection with the server, and the connection contains the verification information token obtained after the login is successful, which is used for server-side authentication. If the login fails, no connection is established. This processing method ensures the security of data transmission and avoids data leakage.

[0109] In addition, it should be noted that in the WebSocket protocol, if the WebSocket connection channel between the front-end page and the server is idle for a long time, that is, when there is no traffic transmission, the WebSocket connection between the front-end page and the server will be automatically closed. In order to avoid this situation, this application sends heartbeat information at preset intervals to ensure that the front-end page and the server will not be idle for a long time, thereby ensuring that the WebSocket connection will not be closed suddenly.

[0110] Optionally, the first detection module further includes: a first detection unit, a first determination unit, and a second determination unit. The first detection unit is used to detect whether the server returns the reply information corresponding to the heartbeat information within the target duration; the first determination unit is used to determine that the connection state is the first state when the server returns the reply information within the target duration; the second determination unit is used to determine that the connection state is the second state when the server does not return the reply information within the target duration, wherein the second state indicates that the data communication connection is in an abnormal connection state.

[0111] Optionally, the above target duration can be customized. If the server can normally receive the heartbeat information sent by the client and determines that the verification information in the heartbeat information is correct, the server will return a reply message to the client within the target duration. After the client receives the reply message, the client will determine that the data communication connection currently established with the server is in a normal connection state. If the client does not receive the reply message returned by the server within the target duration, the client will determine that the data communication connection currently established with the server is in an abnormal connection state.

[0112] It should be noted that there may be many reasons why the client does not receive the reply information returned by the server within the target time. For example, the verification information in the heartbeat message is invalid, resulting in the server not generating a reply message at all; or, due to a failure on the server, the server does not receive the heartbeat message or cannot send a reply message; or, due to an unstable network between the server and the client, the transmission time of the heartbeat message and the reply message is too long.

[0113] From the above content, it can be seen that the present application provides a method for self-diagnosis of the data communication connection status. Only when the data communication connection is in a normal connection state will the client initiate a message subscription to the server, thereby ensuring the stability of the information interaction between the client and the server.

[0114] Optionally, the message processing device also includes: a second detection module, a first determination module and a second determination module. Among them, the second detection module is used to re-establish the data communication connection with the server through the target component, and detect whether the connection state of the re-established data communication connection is the first state; the first determination module is used to determine that the data communication connection between the client and the server is successfully established when it is detected that the connection state of the re-established data communication connection is the first state; the second determination module is used to determine that the data communication connection between the client and the server fails to be established when it is detected that the connection state of the re-established data communication connection is the second state; the statistical data communication connection establishment failure times, and when the times are greater than a preset threshold, prohibiting the re-establishment of the data communication connection.

[0115] Optional, such as Figure 3 As shown, the client is configured with a strategy for automatic reconnection after WebSocket connection is disconnected, and when the number of automatic reconnections exceeds a preset threshold, automatic reconnection is stopped. Specifically, by configuring a strategy for automatic reconnection after WebSocket connection is disconnected and the number of reconnections has a maximum upper limit, the problem of unlimited reconnection between the front-end page and the server can be avoided, thereby saving server resources.

[0116] It should be noted that if Figure 3 As shown in the figure, before the client initiates a message subscription request to the server through the message subscription function, it will first determine the status of the current WebSocket connection. If the connection is disconnected, it will set automatic reconnection again, and wait for the reconnection to succeed before initiating a subscription message to the backend. This ensures that when the network is temporarily interrupted, as long as the number of automatic reconnections of the WebSocket connection does not exceed the preset threshold, the WebSocket connection can be reestablished after the network is restored, and will not affect the normal use of the business module. It should also be noted that when the business module determines whether a message subscription is currently required, it also needs to communicate with the server through the HTTP protocol. If normal communication is possible, it means that the network has returned to normal. At this time, the WebSocket connection can be reestablished when subscribing to the message, and it can be successfully established normally. When the WebSocket reconnects successfully, the client will reset the number of consecutive failures to establish a connection.

[0117] Optionally, the calling module further includes: a first sending unit and a second sending unit. The first sending unit is used to send a message subscription request to a first subcomponent in the target component, wherein the first subcomponent is used to establish a data transmission channel between the business module and the target component; and the second sending unit is used to send the message subscription function to the target business module through the first subcomponent.

[0118] Optional, such as Figure 3 As shown, the WebSocket component uses React's Context to expose the encapsulated message subscription function to the business module. React is a JavaScript library for building front-end pages, and Context is a context mechanism. Specifically, the purpose of Context design is to share data that is "global" for a component tree. Context allows this data to be "broadcasted" to all components under the component tree, and all components can access this data and subsequent data updates. In addition, each Context object returns a ProviderReact component (i.e., the first subcomponent mentioned above), which allows the consumer component (i.e., the business module) to subscribe to changes in Context. The first subcomponent receives a value attribute and passes it to the consumer component. A first subcomponent can have a corresponding relationship with multiple consumer components. In the specific implementation process, the WebSocket component calls React's createContext to create a context environment, i.e., a Context object. Then, the WebSocket component deconstructs the Provider React component from the Context object, sets the value to the encapsulated message subscription function, and uses each business module as its subcomponent, i.e., the consumer component.

[0119] From the above content, it can be seen that in this application, the WebSocket component uses the context mechanism of react to expose the encapsulated message subscription function to each business module. Each business module reads the message subscription function from the context of react, and then initiates a message subscription request related to its own module according to its own needs, thereby achieving the purpose of rendering the functional components related to its own module.

[0120] Optionally, the message processing device further includes: a second sending module, configured to send the message subscription function in parallel to the multiple business modules through the first subcomponent when the multiple business modules initiate consumption subscription requests at the same time.

[0121] Among them, in the prior art, if multiple business modules initiate consumption subscription requests at the same time, each business module needs to establish a WebSocket connection with the server, which will lead to the problem of too many WebSocket connections corresponding to the server, increasing the resource overhead of the server. In this application, each business module will not create its own WebSocket connection, and multiple business modules will obtain the message subscription function encapsulated in the WebSocket component through the first subcomponent, and the WebSocket component will only establish a WebSocket connection with the server. Therefore, in this application, the server does not need to spend too much resources to maintain multiple WebSocket connections, thereby achieving the effect of reducing the resource overhead of the server.

[0122] In an optional embodiment, Figure 4 A functional schematic diagram of a service module according to an embodiment of the present application is shown, such as Figure 4 As shown in the figure, no matter it is business module 1 or business module 2, each business module does not need to pay attention to the information related to the WebSocket connection, such as establishing a WebSocket connection, sending heartbeat information, authentication, WebSocket connection disconnection and reconnection, and other operation information. A WebSocket component can be used by multiple business modules in the entire front-end page. In addition, each business module can obtain the message subscription function exposed by the WebSocket component through the context mechanism. At the same time, each business module initiates a message subscription request related to its own module according to its own needs, and after receiving the business information returned by the server, it renders the corresponding functional component according to the business information. Finally, when the business module determines that there is no new data change, the business module cancels the message subscription according to the instance returned by the message subscription function, that is, sends a message subscription cancellation request to the server.

[0123] in addition, Figure 5 FIG. 1 shows a schematic diagram of the relationship between a target component and a service module according to an embodiment of the present application. Figure 5 As shown in the figure, the WebSocket component is the producer of Context, and each business module is the consumer of Context. The WebSocket component implements operations such as establishing WebSocket connection, sending heartbeat information, authentication, WebSocket connection disconnection and reconnection, etc. Each business module only needs to focus on its own business. At the same time, the WebSocket component provides a message subscription function containing the WebSocket connection channel to each business module. Each business module initiates a message subscription request when needed and renders the functional component according to the business information returned by the server.

[0124] The following is a code example based on constructing the target component, business module 1, and business module 2:

[0125] WebSocket Components:

[0126] exportconst wsContext=createContext({subscribe:{}});

[0127] const{Provider}=wsContext;

[0128] WebSocket connection related

[0129] Message subscription function subscribe

[0130] / / children is a Web-based consumer component that contains a business module

[0131] return<Provider value={{subscribe}}> {children}; Business module 1:

[0132]

[0133] Business Module 2:

[0134]

[0135]

[0136] From the above content, it can be seen that the present application achieves the purpose of independence between the target component and the business module by separately constructing the business module and the target component. Since the corresponding codes of the two are completely decoupled, the business module does not need to pay attention to the data communication connection, but only needs to be responsible for processing the corresponding business information. The target component also does not need to pay attention to which messages the business module needs to subscribe to, but only needs to be responsible for establishing the data communication connection between the client and the server. The target component and the business module each have their own responsibilities, which not only improves the maintainability of the target component and the business module, but also improves the interaction stability between the business module and the target component, and improves the information interaction efficiency between the business module and the server.

[0137] Example 3

[0138] According to another aspect of the embodiment of the present application, a computer-readable storage medium is further provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the message processing method in the above-mentioned embodiment 1 when it is run.

[0139] Example 4

[0140] According to another aspect of an embodiment of the present application, an electronic device is also provided, which includes one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors are implemented to run the programs, wherein the programs are configured to execute the message processing method of the above-mentioned embodiment 1 when running.

[0141] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0142] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0143] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be 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 interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0144] 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 units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0145] In addition, each functional unit in each embodiment of the present application 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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0146] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable 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 application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0147] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A message processing method, characterized in that: include: Obtaining a message subscription request initiated by a target business module in the client, wherein the target business module is any one of a plurality of business modules, each of the business modules is used to process business information of a business type, and the business module is composed of a first code; Calling a message subscription function encapsulated in a target component according to the message subscription request, wherein the target component is used to establish a data communication connection between the client and the server, the target component is composed of a second code, and the first code and the second code are independent of each other; Sending the message subscription request to the server based on the message subscription function; Receive the target information returned by the server based on the message subscription request, and render the functional components in the target business module according to the target information.

2. The method according to claim 1, characterized in that Before obtaining the message subscription request initiated by the target service module in the client, the method further includes: Sending heartbeat information to the server at preset intervals, wherein the heartbeat information at least includes verification information, and the verification information is used to represent the identity information of the login object logging into the client; Detecting the connection status of the data communication connection according to the heartbeat information; When the connection state is a first state, a message subscription request initiated by the target service module is obtained, wherein the first state represents that the data communication connection is in a normal connection state.

3. The method according to claim 2, characterized in that Sending heartbeat information to the server at a preset interval includes: Acquire login information on the client, wherein the login information at least includes the account information and password information of the login object; Receiving a verification result after the server verifies the login information according to a preset list, wherein the preset list is used to record account information and password information having login authority of the client; If the login information is successfully verified, obtaining verification information generated by the server according to the login information; Establishing the data communication connection with the server through the target component; The heartbeat information is generated according to the verification information, and the heartbeat information is sent to the server at intervals of the preset time length.

4. The method according to claim 2, characterized in that: Detecting the connection state of the data communication connection according to the heartbeat information includes: Detect whether the server returns the reply information corresponding to the heartbeat information within the target time; When the server returns the reply information within the target time period, determining that the connection state is the first state; When the server does not return the reply information within the target time period, it is determined that the connection state is a second state, wherein the second state represents that the data communication connection is in an abnormal connection state.

5. The method according to claim 4, characterized in that After determining that the connection state is the second state, the method further includes: Re-establishing the data communication connection with the server through the target component, and detecting whether the connection state of the re-established data communication connection is the first state; In a case where it is detected that the connection state of the re-established data communication connection is the first state, determining that the data communication connection between the client and the server is successfully established; In the case where it is detected that the connection state of the re-established data communication connection is the second state, determining that the establishment of the data communication connection between the client and the server fails; The number of failures in establishing the data communication connection is counted, and when the number is greater than a preset threshold, re-establishing the data communication connection is prohibited.

6. The method according to claim 1, characterized in that Calling the message subscription function encapsulated in the target component according to the message subscription request includes: Sending the message subscription request to a first subcomponent in the target component, wherein the first subcomponent is used to establish a data transmission channel between the business module and the target component; The message subscription function is sent to the target business module through the first subcomponent.

7. The method according to claim 6, characterized in that The method further comprises: When a plurality of the business modules initiate consumption subscription requests simultaneously, the message subscription function is sent in parallel to the plurality of the business modules through the first subcomponent.

8. A message processing device, characterized in that: include: An acquisition module, used for acquiring a message subscription request initiated by a target business module in a client, wherein the target business module is any one of a plurality of business modules, each of the business modules is used for processing business information of a business type, and the business module is composed of a first code; A calling module, used for calling a message subscription function encapsulated in a target component according to the message subscription request, wherein the target component is used for establishing a data communication connection between the client and the server, the target component is composed of a second code, and the first code and the second code are independent of each other; A sending module, used for sending the message subscription request to the server based on the message subscription function; The receiving module is used to receive the target information returned by the server based on the message subscription request, and render the functional components in the target business module according to the target information.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the message processing method described in any one of claims 1 to 7.

10. An electronic device, characterized in that: The electronic device comprises one or more processors; a storage device for storing one or more programs, which, when the one or more programs are executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the message processing method described in any one of claims 1-7 when running.

Citation Information

Patent Citations

  • Method for pushing messages in real time and server

    CN103929497A

  • Method and device for communication between server and client, and communication system

    CN111343236A