Message concurrency method, device, computer device and storage medium
Patent Information
- Application Number
- CN202211291226.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-17
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2042-10-17
AI Technical Summary
[0003]本发明实施例提供一种消息并发方法、装置、计算机设备及存储介质,以解决消息并发处理困难的问题
[0057]上述消息并发方法、装置、计算机设备及存储介质,服务器在接收到消息并发请求后,先基于消息并发请求,确定渲染进程和主进程之间通信的至少一个预设进程事件和每一预设进程事件对应的事件句柄,接着采用渲染进程监听至少一个预设进程事件,将被点击触发的预设进程事件确定为目标进程事件,获取目标进程事件对应的目标事件类型,然后采用主进程进行消息生成,获取目标事件类型相对应的目标并发消息,最后基于目标进程事件对应的事件句柄,将目标并发消息发送至目标订阅者,从而使服务器通过复用主进程与渲染进程之间的事件句柄的方式,将生成的目标并发消息发送到目标订阅者,使服务器作为主进程与渲染进程之间的通信桥梁,在重发通信消息时,可以不用再从主进程为起点重发通信消息,以便于实现消息并发处理。
Smart Images

Figure CN115629888B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a message concurrency method, apparatus, computer device, and storage medium. Background Technology
[0002] Currently, most Electron desktop applications (Electron is a framework for building cross-platform desktop applications using JavaScript, HTML, and CSS) use IPC controllers for inter-process communication, which is largely inherited from Node.js's EventEmitter. However, the communication mechanism built on EventEmitter requires recalculating the computation logic from the message's initiation point when re-initiating a message, making concurrent message processing difficult. Summary of the Invention
[0003] This invention provides a message concurrency method, apparatus, computer device, and storage medium to solve the problem of difficulty in message concurrency processing.
[0004] A message concurrency method includes:
[0005] Retrieve messages and make concurrent requests;
[0006] Based on the message concurrency request, at least one preset process event for communication between the rendering process and the main process and an event handle corresponding to each preset process event are determined.
[0007] The rendering process listens to at least one of the preset process events, determines the preset process event triggered by the click as the target process event, and obtains the target event type corresponding to the target process event;
[0008] The main process is used to generate messages and obtain the target concurrent messages corresponding to the target event type;
[0009] Based on the event handle corresponding to the target process event, the target concurrent message is sent to the target subscriber.
[0010] Further, determining at least one preset process event for communication between the rendering process and the main process and an event handle corresponding to each preset process event based on the message concurrency request includes:
[0011] Based on the concurrent message requests, the process communication protocol between the rendering process and the main process is determined.
[0012] Read the process communication protocol to obtain at least one preset process event and an event handle corresponding to each preset process event.
[0013] Furthermore, the step of using a rendering process to listen to at least one of the preset process events, determining the preset process event triggered by the click as the target process event, and obtaining the target event type corresponding to the target process event includes:
[0014] The rendering process is used to render and register at least one of the preset process events, and the event registration information is obtained;
[0015] When the rendering process detects that the preset process event has been triggered, the preset process event triggered by the click is identified as the target process event;
[0016] From the event registration information, determine the target event type corresponding to the target process event.
[0017] Furthermore, the step of using a main process to generate messages and obtain the target concurrent messages corresponding to the target event type includes:
[0018] The main process retrieves data structure information corresponding to the target event type from the database.
[0019] The main process generates messages based on the data structure information and obtains the target concurrent messages corresponding to the target event type.
[0020] Furthermore, the data structure information includes the data table structure and primary key values;
[0021] The step of using the main process to generate messages based on the data structure information and obtaining the target concurrent message corresponding to the target event type includes:
[0022] The main process generates target data that matches the data table structure, excluding the primary key value;
[0023] The main process accesses the inter-process communication entry point to register messages, generates messages based on the primary key value and the target data, and obtains the target concurrent messages corresponding to the target event type.
[0024] Furthermore, after obtaining the target concurrent message corresponding to the target event type, the method further includes pushing the target concurrent message to a message queue;
[0025] The step of sending the target concurrent message to the target subscriber based on the event handle corresponding to the target process event includes:
[0026] Based on the message queue and the event handle corresponding to the target process event, the target concurrent message is sent to the target subscriber.
[0027] Further, the step of sending the target concurrent message to the target subscriber based on the message queue and the event handle corresponding to the target process event includes:
[0028] When the message queue is consumed normally, the processing function corresponding to the event handle is called based on the event handle corresponding to the target process event;
[0029] Based on the processing function, the target concurrent message is sent to the target subscriber.
[0030] A message concurrency device, comprising:
[0031] The request retrieval module is used to retrieve messages and make concurrent requests.
[0032] The event determination module is used to determine, based on the message concurrency request, at least one preset process event for communication between the rendering process and the main process and an event handle corresponding to each preset process event;
[0033] The type acquisition module is used to listen to at least one of the preset process events using the rendering process, determine the preset process event triggered by the click as the target process event, and obtain the target event type corresponding to the target process event;
[0034] The message acquisition module is used to generate messages using the main process and acquire the target concurrent messages corresponding to the target event type.
[0035] The message sending module is used to send the target concurrent message to the target subscriber based on the event handle corresponding to the target process event.
[0036] Furthermore, the event determination module includes:
[0037] The protocol determination submodule is used to determine the process communication protocol between the rendering process and the main process based on the concurrent message request.
[0038] The protocol reading submodule is used to read the process communication protocol and obtain at least one preset process event and an event handle corresponding to each preset process event.
[0039] Furthermore, the type acquisition module includes:
[0040] The information acquisition submodule is used to render and register at least one of the preset process events using the rendering process, and to acquire event registration information;
[0041] The event determination submodule is used to determine the preset process event triggered by the click as the target process event when the rendering process listens for the preset process event being triggered.
[0042] The event type submodule is used to determine the target event type corresponding to the target process event from the event registration information.
[0043] Furthermore, the message acquisition module includes:
[0044] The data structure submodule is used to retrieve data structure information corresponding to the target event type from the database using the main process;
[0045] The message generation submodule is used by the main process to generate messages based on the data structure information and obtain the target concurrent messages corresponding to the target event type.
[0046] Furthermore, the message generation submodule includes:
[0047] The data generation unit is used by the main process to generate target data that matches the data table structure, excluding the primary key value;
[0048] The message acquisition unit is used to register messages by accessing the inter-process communication entry point of the main process, generate messages based on the primary key value and the target data, and acquire the target concurrent messages corresponding to the target event type.
[0049] Furthermore, the message concurrency device also includes:
[0050] The message queue module is used to push the target concurrent messages to the message queue;
[0051] The message sending module is further configured to send the target concurrent message to the target subscriber based on the message queue and the event handle corresponding to the target process event.
[0052] Furthermore, the message sending module includes:
[0053] The queue consumption submodule is used to call the processing function corresponding to the event handle based on the event handle corresponding to the target process event when the message queue is consumed normally.
[0054] The message sending submodule is used to send the target concurrent message to the target subscriber based on the processing function.
[0055] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-described message concurrency method when executing the computer program.
[0056] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described message concurrency method.
[0057] The aforementioned message concurrency method, apparatus, computer device, and storage medium, upon receiving a message concurrency request, first determine at least one preset process event and the corresponding event handle for each preset process event based on the message concurrency request. Then, the rendering process listens for at least one preset process event, identifies the preset process event triggered by the click as the target process event, obtains the target event type corresponding to the target process event, and then uses the main process to generate a message, obtaining the target concurrent message corresponding to the target event type. Finally, based on the event handle corresponding to the target process event, the target concurrent message is sent to the target subscriber. This allows the server to send the generated target concurrent message to the target subscriber by reusing the event handle between the main process and the rendering process, enabling the server to act as a communication bridge between the main process and the rendering process. When retransmitting communication messages, it is not necessary to retransmit the communication messages starting from the main process, thus facilitating concurrent message processing. Attached Figure Description
[0058] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 This is a schematic diagram of an application environment for a message concurrency method according to an embodiment of the present invention;
[0060] Figure 2 This is a flowchart of a message concurrency method according to an embodiment of the present invention;
[0061] Figure 3 This is another flowchart of a message concurrency method in one embodiment of the present invention;
[0062] Figure 4 This is another flowchart of a message concurrency method in one embodiment of the present invention;
[0063] Figure 5 This is another flowchart of a message concurrency method in one embodiment of the present invention;
[0064] Figure 6 This is another flowchart of a message concurrency method in one embodiment of the present invention;
[0065] Figure 7 This is another flowchart of a message concurrency method in one embodiment of the present invention;
[0066] Figure 8This is a schematic diagram of a message concurrency device according to an embodiment of the present invention;
[0067] Figure 9 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0068] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0069] The message concurrency method provided in this embodiment of the invention can be applied to, for example... Figure 1 The application environment shown is illustrated. Specifically, this message concurrency method is applied in a message concurrency system, which includes, for example, […]. Figure 1 The diagram illustrates a client and server. The client and server communicate over a network to enable concurrent message processing. The client, also known as the user terminal, is the program that provides local services to the client, corresponding to the server. Clients can be installed on, but are not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0070] In one embodiment, such as Figure 2 As shown, a message concurrency method is provided, which can be applied to... Figure 1 Taking the server in the example, the following steps are included:
[0071] S201: Message retrieval concurrent request.
[0072] Message concurrency requests refer to requests used to concurrently process communication messages between processes on an application.
[0073] As an example, the server receives the message and makes concurrent requests through a client. This client has an operating system installed. Optionally, the operating system includes, but is not limited to, Windows, Linux, Mac, or Unix systems. At least one application is deployed on this operating system. This at least one application includes, but is not limited to, desktop applications or other applications with different functionalities. Each application runs at least one process. In this embodiment, the desktop application is deployed to the operating system via Electron. Electron provides a pure JavaScript environment for building desktop applications in real time. Specifically, when the desktop application starts, a main process is automatically created. This main process is used to create the application window of the desktop application and handle the interaction between the user and the application window. Optionally, there can be one or more application windows. Each application window executes a corresponding rendering process. Each rendering process is used to render the data corresponding to the communication message sent by the main process into the application window. For example, the main process uses a BrowserWindow instance to create a page. Each BrowserWindow instance runs the application window in its own rendering process.
[0074] As an example, the server and client establish a connection via WebSocket. WebSocket is a protocol that enables full-duplex communication over a single TCP (Transmission Control Protocol) connection, allowing the server to proactively send messages to the client. In this example, after the server establishes a connection with the client via WebSocket, the user can send concurrent message requests to the server through the client, instructing the server to concurrently process communication messages between the main process and the rendering process of the desktop application on the client.
[0075] As an example, the main process and the rendering process in a desktop application can communicate through a preset communication method. Optionally, this preset communication method can be either a subscriber pattern or an observer pattern. This embodiment uses the subscriber pattern to illustrate the communication between the main process and the rendering process in a desktop application.
[0076] For example, the main process acts as the publisher of communication messages, and the rendering process acts as the subscriber. When the main process sends a communication message and the rendering process receives it, the main process uses the application window's webContents to send the message, and the rendering process receives it through ipcRenderer. Conversely, when the rendering process sends a communication message and the main process receives it, the rendering process uses ipcRenderer to send the message, and the main process uses ipcMain to receive it.
[0077] As an example, in related technologies, the communication process between the main process and the rendering process in a desktop application is as follows: the main process sends communication messages from the message queue to the rendering process; after receiving the communication message, the rendering process sends a message receipt corresponding to the communication message back to the main process; and after receiving the message receipt, the main process pushes the message queue forward to send the next communication message. Therefore, when performing concurrent message processing—that is, when the main process needs to resend a communication message to the rendering process—each time, the communication message needs to be resent from the main process as the starting point, making concurrent message processing difficult.
[0078] To address the aforementioned issues, in this embodiment, the server concurrently processes messages sent by the client. In subsequent steps, the server acts as a communication bridge between processes within the desktop application, thus avoiding the need to resend communication messages each time starting from the main process, thereby facilitating concurrent message processing.
[0079] S202: Based on message concurrency requests, determine at least one preset process event for communication between the rendering process and the main process, and the event handle corresponding to each preset process event.
[0080] Among them, preset process events refer to custom-defined events between the rendering process and the main process. An event handle is a handle corresponding to each preset process event. Each event handle corresponds to a handler function or statement that executes the preset process event. This handler function or statement is user-defined and used to execute the corresponding preset process event.
[0081] As an example, after receiving a concurrent message request, the server determines, based on the concurrent message request, at least one preset process event for communication between the rendering process and the main process, and an event handle corresponding to each preset process event. For instance, the desktop application could be a work communication program for internal employees of an enterprise. The preset process events for communication between the rendering process and the main process of this work communication program could be events such as receiving a message, joining a group, group information changes, personal information changes, adding or deleting friends from the group, etc. Each preset process event corresponds to an event handle.
[0082] In this embodiment, the server determines at least one preset process event and the event handle corresponding to each preset process event through message concurrency requests. In subsequent steps, the server reuses the event handle corresponding to each preset process event to complete message concurrency processing based on the event handle corresponding to the preset process event, thereby avoiding the sending of communication messages through the publisher of the communication message, so as to facilitate message concurrency processing of the communication messages.
[0083] S203: Use the rendering process to listen to at least one preset process event, determine the preset process event triggered by the click as the target process event, and obtain the target event type corresponding to the target process event.
[0084] The target process event is a preset process event triggered by a click. The target event type refers to the event type corresponding to the target process event.
[0085] As an example, the rendering process renders at least one preset process event in the application window and listens for at least one preset process event. When a user triggers any preset process event rendered in the application window, the triggered preset process event is identified as the target process event, and the target event type corresponding to the target process event is obtained. It should be noted that when a preset process event in the rendering process is triggered, the rendering process sends the event type of the triggered preset process event to the main process. The server can then obtain the event type of the triggered preset process event from this information and determine it as the target event type corresponding to the target process event. For example, the target event type could be a notification event or a data change event. The data change event could be a data deletion event or a data addition event. For example, receiving a message is a notification event, while joining a group, changing group information, changing personal information, adding or deleting friends in a group are data change events.
[0086] In this embodiment, the rendering process listens to at least one preset process event, determines the preset process event triggered by the click as the target process event, and obtains the target event type corresponding to the target process event, so that the server can generate a communication message for concurrent message processing based on the target event type in subsequent steps.
[0087] S204: Use the main process to generate messages and obtain the target concurrent messages corresponding to the target event type.
[0088] Among them, the target concurrent message is the communication message corresponding to the target event type.
[0089] As an example, the server retrieves the target concurrent message corresponding to the target event type through the main process, based on the target event type. Optionally, this target concurrent message can be generated according to preset message generation logic. The preset message generation logic refers to custom-defined logic used to generate the target concurrent message. Optionally, this preset message generation logic can randomly generate the target concurrent message for concurrent message processing.
[0090] Furthermore, the server registers a message queue by accessing the communication entry point between the main process and the rendering process. Optionally, the message queue can be registered via an SQLite database. After the server generates messages using the main process and obtains the target concurrent message corresponding to the target event type, it pushes the target concurrent message into the message queue so that it can be sent to the subscriber corresponding to the target concurrent message in the message concurrency processing process in subsequent steps.
[0091] S205: Based on the event handle corresponding to the target process event, send the target concurrent message to the target subscriber.
[0092] Here, the target subscriber refers to the subscriber corresponding to the target concurrent message. For example, the target subscriber is the rendering process that renders the target process event.
[0093] As an example, the server sends the target concurrent message to the target subscriber based on the event handle corresponding to the target process event. This allows the server to reuse the event handle between the main process and the rendering process to send the generated target concurrent message to the target subscriber, i.e., the rendering process that renders the target process event. The rendering process renders the target concurrent message, realizing concurrent message processing. Thus, the server acts as a communication bridge between the main process and the rendering process. When retransmitting communication messages, it does not need to retransmit the communication messages starting from the main process, which facilitates concurrent message processing.
[0094] In this embodiment, after receiving a message concurrency request, the server first determines at least one preset process event and the event handle corresponding to each preset process event based on the message concurrency request. Then, the rendering process listens for at least one preset process event, identifies the preset process event triggered by the click as the target process event, obtains the target event type corresponding to the target process event, and then uses the main process to generate a message, obtains the target concurrent message corresponding to the target event type, and finally sends the target concurrent message to the target subscriber based on the event handle corresponding to the target process event. This allows the server to send the generated target concurrent message to the target subscriber by reusing the event handle between the main process and the rendering process, making the server a communication bridge between the main process and the rendering process. When retransmitting communication messages, it is not necessary to retransmit the communication messages starting from the main process, so as to realize message concurrency processing.
[0095] In one embodiment, such as Figure 3 As shown, in step S202, based on the message concurrency request, at least one preset process event for communication between the rendering process and the main process and the event handle corresponding to each preset process event are determined, including:
[0096] S301: Determines the process communication protocol between the rendering process and the main process based on concurrent message requests.
[0097] The inter-process communication protocol is the communication protocol between the rendering process and the main process. Optionally, there can be one or more inter-process communication protocols, which can be customized by the user. Each inter-process communication protocol is configured with a corresponding preset process event and an event handle for the preset process event. Optionally, the inter-process communication protocol between the rendering process and the main process can be defined based on EventEmitter in Node.js.
[0098] As an example, after receiving a message concurrency request, the server determines all process communication protocols between the rendering process and the main process based on the message concurrency request, so as to determine at least one preset process event and the event handle corresponding to each preset process event for communication between the rendering process and the main process.
[0099] S302: Read the process communication protocol and obtain at least one preset process event and the event handle corresponding to each preset process event.
[0100] As an example, after the server reads the inter-process communication protocol, since each inter-process communication protocol configuration has a corresponding preset process event and an event handle corresponding to the preset process event, the server can read at least one preset process event and an event handle corresponding to each preset process event from the inter-process communication protocol.
[0101] In this embodiment, the server determines the process communication protocol between the rendering process and the main process, reads the process communication protocol, and obtains at least one preset process event and the event handle corresponding to each preset process event. This enables the server to send the generated target concurrent messages to the target subscribers in subsequent steps by reusing the event handles between the main process and the rendering process. As a communication bridge between the main process and the rendering process, the server can avoid retransmitting communication messages from the main process when retransmitting them, thus facilitating concurrent message processing.
[0102] In one embodiment, such as Figure 4 As shown, in step S203, the rendering process listens to at least one preset process event, determines the preset process event triggered by the click as the target process event, and obtains the target event type corresponding to the target process event, including:
[0103] S401: Use a rendering process to render and register at least one preset process event, and obtain event registration information.
[0104] The event registration information refers to the event information obtained by the rendering process from rendering and registering at least one preset process event. Optionally, the event registration information includes, but is not limited to, the event type, event name, and corresponding event handle.
[0105] As an example, the server reads at least one preset process event and its corresponding event handle from a custom-configured inter-process communication protocol. It should be noted that reading at least one preset process event includes reading the event type and event name for each preset process event. The server generates a registration message using the rendering process. This registration message includes, but is not limited to, the event type, event name, and event handle corresponding to the preset process events. The server sends this registration message to the main process using `ipcRenderer` in the rendering process. The main process listens for this registration message using `ipcMain` and simultaneously mounts it to the operating system via the corresponding message initiation function, thereby enabling the rendering and registration of at least one preset process event. Optionally, this message initiation function is the `preload` function in Electron.
[0106] In this embodiment, the server renders and registers at least one preset process event using a rendering process, and determines the event type, event name, and event handle corresponding to each preset process event after registration as event registration information.
[0107] S402: When the rendering process detects that a preset process event has been triggered, the preset process event triggered by the click will be identified as the target process event.
[0108] As an example, the rendering process listens for at least one preset process event that is being rendered in the application window. A user can trigger at least one preset process event that is being rendered in the application window by clicking, and the server identifies the preset process event triggered by the click as the target process event. For example, a user can trigger at least one preset process event that is being rendered in the application window by clicking with the mouse.
[0109] S403: Determine the target event type corresponding to the target process event from the event registration information.
[0110] As an example, since the server has already rendered and registered at least one preset process event by using the rendering process to obtain event registration information, when the user triggers at least one preset process event rendered in the application window by clicking, the server can determine the target event type corresponding to the preset process event triggered by the user's click from the event registration information, that is, the target event type corresponding to the target process event.
[0111] In this embodiment, since the server has already rendered and registered at least one preset process event using the rendering process to obtain event registration information, when the rendering process detects that the preset process event is triggered, it will determine the preset process event triggered by the click as the target process event. Then, it can determine the target event type corresponding to the target process event from the event registration information, so that the server can generate a target concurrent message for message concurrent processing based on the target event type in subsequent steps.
[0112] In one embodiment, such as Figure 5 As shown, in step S204, the main process is used to generate messages and obtain the target concurrent messages corresponding to the target event type, including:
[0113] S501: The main process retrieves the data structure information corresponding to the target event type from the database.
[0114] Among them, data structure information refers to the data structure information corresponding to the target event type.
[0115] As an example, the server uses the main process to retrieve data structure information corresponding to the target event type from the database, based on the target event type. This data structure information is used to generate the target concurrent message.
[0116] Optionally, the database pre-stores data structure information corresponding to the event types of preset process events. Optionally, the database can be an SQLite database. For example, the data structure information includes, but is not limited to, the table structure and the primary key values corresponding to the table structure. For example, the data table structure corresponding to the event type "received message" includes, but is not limited to, message sending time, message receiving time, message content, message sender, and message receiver.
[0117] S502: The main process generates messages based on data structure information and obtains the target concurrent messages corresponding to the target event type.
[0118] As an example, the server uses the main process to retrieve the data structure information corresponding to the target event type from the database. Then, the main process generates a message based on the data structure information to obtain the target concurrent message corresponding to the target event type. In subsequent steps, the target concurrent message is sent to the subscribers corresponding to the target concurrent message.
[0119] In this embodiment, the server obtains data structure information corresponding to the target event type from the database through the main process, and generates a target concurrent message corresponding to the target event type based on the data structure information, so as to perform message concurrent processing through the target concurrent message.
[0120] In one embodiment, such as Figure 6 As shown, in step S502, the data structure information includes the data table structure and primary key value; the main process generates messages based on the data structure information to obtain the target concurrent messages corresponding to the target event type, including:
[0121] S601: The main process generates target data that matches the data table structure, excluding the primary key value, based on the data table structure.
[0122] The target data refers to the data that matches the data table structure.
[0123] As an example, the server uses the main process to generate target data that matches the data table structure, excluding the primary key value. Optionally, the server uses the main process to randomly generate target data that matches the data table structure, excluding the primary key value. Alternatively, other methods can be used to generate target data that matches the data table structure, excluding the primary key value, as long as the generated target data satisfies the data table structure corresponding to the target event type.
[0124] S602: The main process accesses the inter-process communication entry point to register messages, generates messages based on the primary key value and target data, and obtains the target concurrent messages corresponding to the target event type.
[0125] As an example, the server uses the main process to access the communication entry point between the main process and the rendering process for message registration. Messages are generated based on primary key values and target data to obtain target concurrent messages corresponding to the target event type. For instance, the server uses the main process to access the communication entry point between the main process and the rendering process to register primary key values and target data in an SQLite database, thereby obtaining target concurrent messages corresponding to the target event type. This allows the rendering process to render the primary key values and target data stored in the SQLite database using the target concurrent messages.
[0126] In this embodiment, the server, through the main process, generates target data that matches the data table structure except for the primary key value, based on the data table structure. Then, based on the primary key value and the target data, it generates target concurrent messages corresponding to the target event type, so as to perform concurrent message processing through the target concurrent messages.
[0127] In one embodiment, after step S602, after obtaining the target concurrent message corresponding to the target event type, the method further includes pushing the target concurrent message to the message queue; in step S205, sending the target concurrent message to the target subscriber based on the event handle corresponding to the target process event includes: sending the target concurrent message to the target subscriber based on the message queue and the event handle corresponding to the target process event.
[0128] As an example, after the server obtains the target concurrent message corresponding to the target event type, it pushes the target concurrent message to the message queue. When the message queue is consumed by the rendering process, the server retrieves the target data corresponding to the target concurrent message from the SQLite database, and based on the event handle corresponding to the target process event, calls the corresponding processing function or statement to send the target data corresponding to the target concurrent message to the target subscriber. This allows the server to send the generated target concurrent message to the target subscriber by reusing the event handle between the main process and the rendering process. The server acts as a communication bridge between the main process and the rendering process. When retransmitting communication messages, it is not necessary to retransmit the communication messages starting from the main process, so as to realize concurrent message processing.
[0129] In one embodiment, such as Figure 7 As shown, in step S205, based on the message queue and the event handle corresponding to the target process event, the target concurrent message is sent to the target subscriber, including:
[0130] S701: When the message queue is consumed normally, the processing function corresponding to the event handle is called based on the event handle corresponding to the target process event.
[0131] As an example, the server sends the target concurrent message in the message queue to the target subscriber, that is, sends the target concurrent message in the message queue to the rendering process. After the rendering process receives the target concurrent message, it sends the message receipt corresponding to the target concurrent message to the server. After the server receives the message receipt, it confirms that the message queue has been consumed normally, and then calls the processing function corresponding to the event handle based on the event handle corresponding to the target process event.
[0132] S702: Based on the processing function, send the target concurrent messages to the target subscribers.
[0133] As an example, after the message queue is consumed normally, the server calls the processing function corresponding to the event handle corresponding to the target process event, and sends the target concurrent message to the target subscriber through the processing function. In other words, the server sends the generated target concurrent message to the target subscriber by reusing the event handle between the main process and the rendering process.
[0134] In this embodiment, when the message queue is consumed normally, the processing function corresponding to the event handle corresponding to the target process event is called. The server, based on the event handle corresponding to the target process event, calls the processing function corresponding to the event handle to send the target concurrent message to the target subscriber. Thus, the server acts as a communication bridge between the main process and the rendering process by reusing the event handle between the main process and the rendering process. When retransmitting communication messages, it is not necessary to retransmit the communication messages starting from the main process, so as to realize concurrent message processing.
[0135] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0136] In one embodiment, a message concurrency device is provided, which corresponds one-to-one with the message concurrency methods described in the above embodiments. For example... Figure 8 As shown, the concurrent message processing device includes a request acquisition module 10, an event determination module 20, a type acquisition module 30, a message acquisition module 40, and a message sending module 50. Detailed descriptions of each functional module are as follows:
[0137] Request retrieval module 10 is used to retrieve messages and make concurrent requests;
[0138] The event determination module 20 is used to determine, based on the message concurrent request, at least one preset process event and the event handle corresponding to each preset process event in the communication between the rendering process and the main process.
[0139] The type acquisition module 30 is used to listen to at least one preset process event using the rendering process, determine the preset process event triggered by the click as the target process event, and obtain the target event type corresponding to the target process event.
[0140] The message acquisition module 40 is used to generate messages using the main process and acquire the target concurrent messages corresponding to the target event type;
[0141] The message sending module 50 is used to send target concurrent messages to target subscribers based on the event handles corresponding to the target process events.
[0142] Furthermore, the event determination module 20 includes:
[0143] The protocol determination submodule is used to determine the process communication protocol between the rendering process and the main process based on concurrent message requests;
[0144] The protocol reading submodule is used to read the process communication protocol and obtain at least one preset process event and the event handle corresponding to each preset process event.
[0145] Furthermore, the type acquisition module 30 includes:
[0146] The information acquisition submodule is used to render and register at least one preset process event using the rendering process, and to acquire event registration information;
[0147] The event determination submodule is used to determine the preset process event triggered by the click as the target process event when the rendering process listens for the preset process event being triggered.
[0148] The event type submodule is used to determine the target event type corresponding to the target process event from the event registration information.
[0149] Furthermore, the message acquisition module 40 includes:
[0150] The data structure submodule is used by the main process to retrieve data structure information corresponding to the target event type from the database;
[0151] The message generation submodule is used by the main process to generate messages based on data structure information and obtain the target concurrent messages corresponding to the target event type.
[0152] Furthermore, the message generation submodule includes:
[0153] The data generation unit is used by the main process to generate target data that matches the data table structure, excluding the primary key value;
[0154] The message acquisition unit is used to register messages by accessing the inter-process communication entry point of the main process, generate messages based on the primary key value and target data, and acquire the target concurrent messages corresponding to the target event type.
[0155] Furthermore, the message concurrency device also includes:
[0156] The message queue module is used to push concurrent messages to the message queue.
[0157] The message sending module 50 is also used to send target concurrent messages to target subscribers based on the message queue and the event handle corresponding to the target process event.
[0158] Furthermore, the message sending module 50 includes:
[0159] The queue consumption submodule is used to call the processing function corresponding to the event handle based on the event handle corresponding to the target process event when the message queue is consumed normally.
[0160] The message sending submodule is used to send concurrent messages to the target subscribers based on the processing function.
[0161] For specific limitations regarding the message concurrency device, please refer to the limitations on message concurrency methods above, which will not be repeated here. Each module in the aforementioned message concurrency device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independent of the processor in the computer device, or stored in software in the memory of the computer device, so that the processor can call and execute the operations corresponding to each module.
[0162] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database is used for concurrent message processing. The network interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a concurrent message processing method.
[0163] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the message concurrency method described in the above embodiment; to avoid repetition, this will not be repeated here. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the message concurrency device embodiment; to avoid repetition, this will not be repeated here.
[0164] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When executed by a processor, the computer program implements the message concurrency method described in the above embodiment; to avoid repetition, this will not be repeated here. Alternatively, when executed by a processor, the computer program implements the functions of each module / unit in this embodiment of the message concurrency device; to avoid repetition, this will not be repeated here.
[0165] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0166] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0167] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A message concurrency method, characterized in that, include: Retrieve messages and make concurrent requests; Based on the message concurrency request, at least one preset process event for communication between the rendering process and the main process and an event handle corresponding to each preset process event are determined. The rendering process listens to at least one of the preset process events, determines the preset process event triggered by the click as the target process event, and obtains the target event type corresponding to the target process event; The main process retrieves data structure information corresponding to the target event type from the database; the data structure information includes a data table structure and a primary key value; the main process then generates target data, excluding the primary key value, that matches the data table structure. The main process accesses the inter-process communication entry point to register messages, generates messages based on the primary key value and the target data, obtains the target concurrent message corresponding to the target event type, and pushes the target concurrent message to the message queue. Sending the target concurrent message to the target subscriber based on the event handle corresponding to the target process event includes: when the message queue is consumed normally, calling the processing function corresponding to the event handle based on the event handle corresponding to the target process event; Based on the processing function, the target concurrent message is sent to the target subscriber.
2. The message concurrency method as described in claim 1, characterized in that, The step of determining at least one preset process event for communication between the rendering process and the main process and an event handle corresponding to each preset process event based on the message concurrency request includes: Based on the concurrent message requests, the process communication protocol between the rendering process and the main process is determined. Read the process communication protocol to obtain at least one preset process event and an event handle corresponding to each preset process event.
3. The message concurrency method as described in claim 1, characterized in that, The process involves listening to at least one of the preset process events during the rendering process, identifying the preset process event triggered by the click as the target process event, and obtaining the target event type corresponding to the target process event, including: The rendering process is used to render and register at least one of the preset process events, and the event registration information is obtained; When the rendering process detects that the preset process event has been triggered, the preset process event triggered by the click is identified as the target process event; From the event registration information, determine the target event type corresponding to the target process event.
4. The message concurrency method as described in claim 1, characterized in that, The step of sending the target concurrent message to the target subscriber based on the event handle corresponding to the target process event includes: Based on the message queue and the event handle corresponding to the target process event, the target concurrent message is sent to the target subscriber.
5. A message concurrency device, characterized in that, include: The request retrieval module is used to retrieve messages and make concurrent requests. The event determination module is used to determine, based on the message concurrency request, at least one preset process event for communication between the rendering process and the main process and an event handle corresponding to each preset process event; The type acquisition module is used to listen to at least one of the preset process events using the rendering process, determine the preset process event triggered by the click as the target process event, and obtain the target event type corresponding to the target process event; The message acquisition module is used to retrieve data structure information corresponding to the target event type from the database using the main process; the data structure information includes a data table structure and a primary key value; and the main process generates target data that matches the data table structure, excluding the primary key value, based on the data table structure. The main process accesses the inter-process communication entry point to register messages, generates messages based on the primary key value and the target data, obtains the target concurrent message corresponding to the target event type, and pushes the target concurrent message to the message queue. The message sending module is used to send the target concurrent message to the target subscriber based on the event handle corresponding to the target process event; The message sending module includes: when the message queue is consumed normally, calling the processing function corresponding to the event handle based on the event handle corresponding to the target process event; Based on the processing function, the target concurrent message is sent to the target subscriber.
6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the message concurrency method as described in any one of claims 1 to 4.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the message concurrency method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Method and device for generating webpage
CN104951287A
Inter-process communication method, device and system, medium and terminal
CN110399229A