CN114579327A - Cross-process communication method and device, storage medium and electronic equipment - Google Patents

Cross-process communication method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN114579327A
CN114579327A CN202011393241.9A CN202011393241A CN114579327A CN 114579327 A CN114579327 A CN 114579327A CN 202011393241 A CN202011393241 A CN 202011393241A CN 114579327 A CN114579327 A CN 114579327A
Authority
CN
China
Prior art keywords
message
event
query
type
cross
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011393241.9A
Other languages
Chinese (zh)
Inventor
葛均辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Qihu Intelligent Technology Co ltd
Original Assignee
Shenzhen Qihu Intelligent Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Qihu Intelligent Technology Co ltd filed Critical Shenzhen Qihu Intelligent Technology Co ltd
Priority to CN202011393241.9A priority Critical patent/CN114579327A/en
Publication of CN114579327A publication Critical patent/CN114579327A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computer And Data Communications (AREA)

Abstract

The application discloses a cross-process communication method, a cross-process communication device, a storage medium and electronic equipment, and belongs to the technical field of communication. The cross-process communication method comprises the following steps: receiving a first event message from a first process by a cross-process communication center process, identifying the message type of the first event message, inquiring whether a second process related to the message type exists in a pre-stored registry, if so, judging whether the message type of the second process stored in the registry is the same as the message type of the first event message, if not, covering the message type of the first event message with the message type of the second process, generating a second event message, and sending the second event message to the second process. Therefore, when the cross-process communication is carried out, the cross-process communication center process is started to serve as an intermediate carrier of the inter-process communication, the multi-process communication efficiency can be improved, and the development cost is reduced.

Description

Cross-process communication method and device, storage medium and electronic equipment
Technical Field
The invention relates to the technical field of communication, in particular to a cross-process communication method, a cross-process communication device, a cross-process communication storage medium and electronic equipment.
Background
Currently, during application layer development of operating systems, communication between different processes may need to be used. For example, if communication between the process a and the process B is required, a developer is required to manually define the relevant information of the process a and then manually search the relevant information of the process B. And defining a communication method of the process A and the process B by utilizing the relevant information of the process A and the relevant information of the process B, thereby initiating the communication of the process A and the process B. With the development of scientific technology, the number of applications in application equipment is increasing, interprocess communication is required to be realized, a computer needs to generate a message queue in every two interprocess communication, the investment time cost is too high due to the maintenance of a large number of message queues, the efficiency of interprocess communication is reduced, the efficiency of interprocess communication in the prior art cannot meet the existing requirement, so that how to make developers and users convenient to use, the efficiency is improved, and the reduction of design and production cost is a problem to be solved urgently at present.
Disclosure of Invention
The embodiment of the application provides a cross-process communication method, a cross-process communication device, a storage medium and electronic equipment, which can improve the communication efficiency among multiple processes and reduce the development cost. The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a cross-process communication method, including:
receiving a first event message from a first process;
identifying a message type of the first event message;
querying whether a second process associated with the message type exists in a pre-stored registry;
if yes, judging whether the message type of the second process stored in the registry is the same as the message type of the first event message;
if not, generating a second event message after covering the message type of the first event message with the message type of the second process;
and sending the second event message to the second process.
In a second aspect, an embodiment of the present application provides a cross-process query method, including:
generating a query request message; the query request carries a message queue identifier and a first query identifier of a target process;
registering the monitoring event type as a first event type in a registry;
sending the query request message to the target process through a cross-process communication center process;
receiving a query response message returned by the target process through the cross-process communication center process; wherein the query response message carries the first query identifier, and the query response message is the first event type;
and analyzing the query response message to obtain a query result, and storing the query result into a corresponding message queue file.
In a third aspect, an embodiment of the present application provides another cross-process query method, including:
receiving a query request message sent by a source process through a cross-process communication center process; the query request carries a message queue identifier and a first query identifier of a target process;
executing query according to the query request message to obtain a query result;
generating a query response message based on the query result; wherein the query response message carries the first query identifier, and the query response message is the first event type;
and sending the query response message to the source process through the cross-process communication center process.
In a fourth aspect, an embodiment of the present application provides a cross-process communication apparatus, including:
a receiving module for receiving a first event message from a first process;
an identification module for identifying a message type of the first event message;
the query module is used for querying whether a second process associated with the message type exists in a pre-stored registry;
a judging module, configured to judge whether the message type of the second process stored in the registry is the same as the message type of the first event message if the first event message exists;
if not, the generation module is used for generating a second event message after covering the message type of the first event message with the message type of the second process;
and the sending module is used for sending the second event message to the second process.
In a fifth aspect, an embodiment of the present application provides a cross-process query apparatus, where the apparatus includes:
the generating module is used for generating a query request message; the query request carries a message queue identifier and a first query identifier of a target process;
the registration module is used for registering the monitoring event type as a first event type in a registry;
the sending module is used for sending the query request message to the target process through a cross-process communication center process;
the receiving module is used for receiving a query response message returned by the target process through the cross-process communication center process; wherein the query response message carries the first query identifier, and the query response message is the first event type;
and the analysis module is used for analyzing the query response message to obtain a query result and storing the query result into a corresponding message queue file.
In a sixth aspect, an embodiment of the present application provides a cross-process query apparatus, where the apparatus includes:
the receiving module is used for receiving a query request message sent by a source process through a cross-process communication center process; the query request carries a message queue identifier and a first query identifier of a target process;
the query module is used for executing query according to the query request message to obtain a query result;
a generating module, configured to generate a query response message based on the query result; wherein the query response message carries the first query identifier, and the query response message is the first event type;
and the sending module is used for sending the query response message to the source process through the cross-process communication center process.
In a seventh aspect, an embodiment of the present application provides a computer storage medium storing a plurality of instructions, which are adapted to be loaded by a processor and to perform the above-mentioned method steps.
In an eighth aspect, an embodiment of the present application provides an electronic device, including: a memory and a processor; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the above-mentioned method steps.
The beneficial effects brought by the technical scheme provided by some embodiments of the application at least comprise:
when the cross-process communication method, the cross-process communication device, the cross-process communication center process and the electronic equipment work, a first event message from a first process is received, the message type of the first event message is identified, whether a second process related to the message type exists or not is inquired in a pre-stored registry, if yes, whether the message type of the second process stored in the registry is the same as the message type of the first event message or not is judged, if not, after the message type of the second process covers the message type of the first event message, a second event message is generated, and the second event message is sent to the second process. When the cross-process communication is carried out, the cross-process communication center process is started to serve as an intermediate carrier of the inter-process communication, so that the multi-process communication efficiency can be improved, and the development cost can be reduced.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic architecture diagram of a cross-process communication system according to an embodiment of the present application;
fig. 2 is a flowchart illustrating a cross-process communication method according to an embodiment of the present application;
fig. 3 is another schematic flowchart of a cross-process communication method according to an embodiment of the present application;
FIG. 4 is a schematic view of a first configuration of an apparatus provided by an embodiment of the present application;
fig. 5 is a first flowchart of a cross-process query method according to an embodiment of the present application;
FIG. 6 is a second schematic diagram of an apparatus according to an embodiment of the present disclosure;
fig. 7 is a second flowchart of a cross-process query method according to an embodiment of the present application;
FIG. 8 is a schematic diagram of a third structure of an apparatus according to an embodiment of the present disclosure;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The following description refers to the accompanying drawings in which like numerals refer to the same or similar elements throughout the different views, unless otherwise specified. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the application, as detailed in the appended claims.
In the description of the present application, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. The specific meaning of the above terms in the present application can be understood in a specific case by those of ordinary skill in the art. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
In order to solve the above-mentioned problem that the efficiency of the inter-process communication cannot meet the existing requirements due to the fact that the inter-process communication is required to be achieved by a large amount of manual operations of developers for maintenance and the investment time cost is too large as the number of applications in application devices is increased, and the efficiency of the inter-process communication is reduced, a cross-process communication method is particularly provided. The computer system can be a computer system of a smart phone, a notebook computer, a tablet computer and the like.
In the following method embodiments, for convenience of description, only the execution subject of each step is described as a computer capable of running a cross-process communication center process.
The cross-process communication method provided in the embodiment of the present application will be described in detail below with reference to fig. 2 to 3.
Please refer to fig. 1, which is a schematic structural diagram of a cross-process communication system according to an embodiment of the present disclosure. As shown in fig. 1, the cross-process communication system mainly includes a first process, a cross-process communication center process, and a second process, where the processes are a series of sets of computer data and instructions organized according to a specific order, and can receive and transmit data. The cross-process communication center process is a self-defined program with independent function, which is a running activity (i.e. a process) about a certain data set, and different application programs rely on the cross-process communication center process to communicate, for example: the first process sends the event message to the cross-process communication center process, and the cross-process communication center process sends the event message to the second process, so that the cross-process communication of the event can be realized, wherein the first process and the second process can be in the same operating system or different operating systems.
Referring to fig. 2, a flowchart of a cross-process communication method is provided in an embodiment of the present application. The method may comprise the steps of:
s201, receiving a first event message from the first process.
Generally, the first process refers to an event initiating process of inter-process communication, such as: and (3) displaying a process on an interface, wherein the first event message format is an object numbered musical notation JSON format. Before the cross-process communication center process receives the first event message from the first process, the cross-process communication center process needs to complete registration with the first process: after a cross-process communication center process is started, creating a message queue file and distributing a message queue identifier for the message queue file, setting a message type monitored by the message queue file to be a full message type, wherein the full message type indicates that the message queue file is used for storing all event messages sent to the cross-process communication center process, when the event messages monitored by the cross-process communication center process are of a preset message type, analyzing the monitored event messages to obtain corresponding process names and event types, and obtaining a target message queue identifier according to the process names, wherein the target message queue identifier is the identifier of a message queue corresponding to the process sending the monitored event messages, and recording registration information into a registry to complete registration, wherein the registration information comprises the process names, The event type and the target message queue identification.
In one embodiment, after a cross-process communication center completes registration, a query request message from a source process is received, wherein the query request carries a message queue identifier and a first query identifier of a target process, a listening event type registered in a registry by the source process is a first event type, the query request message is sent to the target process, a query response message from the target process is received, wherein the query response message carries the first query identifier and the first event type, and the query response message is sent to the source process.
S202, identifying the message type of the first event message.
Generally, after a cross-process communication center process receives a first event message from a first process, a first event message structure is analyzed, a message header is obtained, and a message type is determined, for example: IPC _ CENTER _ regiostor _ MQ message type, etc.
S203, inquiring whether a second process associated with the message type exists in a pre-stored registry.
Generally, the registry is an important database in the operating system, and is used to store setting information of the system and the application program, when the cross-process communication center process implements the above steps and completes the registration loop, the registration information is recorded in the registry, so that at this time, the cross-process communication center process traverses the registry to query whether there is a second process associated with the message type, for example: if the message type of the first event message is a key click event, inquiring whether the key click event exists in a registry, and if so, determining a second process associated with the key click event, for example: and (5) network transmission management process.
S204, if yes, judging whether the message type of the second process stored in the registry is the same as the message type of the first event message.
Generally, the message type recorded in the registry may be a combination of message types of various event messages monitored by each process, and the message type for identifying the first event message when the message monitoring logic is executed once across the process communication center process only includes one of the message types. Therefore, after the cross-process communication center process queries the pre-stored registry for the existence of the second process associated with the message type, it is further required to determine whether the message type of the second process stored in the registry is the same as the message type of the first event message, for example: analyzing a data format obtained by the first event message, wherein the process name is as follows: the message type is a Remote process: 1024, where 1024 refers to a type of a key click message, a data format stored in a registry, and a process name: the message type is a Remote control Remote process: 1025, where the message type is represented by a number, ranging from 1 to 1024, 1025 represents a key click message type of 1024 and a Real Time Messaging Protocol (RTMP) message type of 1.
S205, if not, generating a second event message after covering the message type of the first event message with the message type of the second process.
Generally, when the cross-process communication center process determines that the message type of the second process stored in the registry is different from the message type of the first event message, the message type of the second process is covered with the message type of the first event message, and then a second event message is generated, for example: copying the first event message to generate a duplicate message, and recording the process name recorded in the registry: the message type is remote process: 1025 covers the process name in the duplicate message: the message type is remote process: 1024, the duplicate message is the process name: the message type is remote process: and 1025, performing format conversion on the duplicate message to generate a second event message.
S206, the second event message is sent to the second process.
Generally, the cross-process communication center process obtains the message queue identifier of the second process in the registry, and sends the second event message to the message queue indicated by the message queue identifier of the second process. In one embodiment, when the message type of the second process is the same as the message type of the first event message, the cross-process communication center process sends the first event message to the second process.
As can be seen from the above, a cross-process communication center process receives a first event message from a first process, identifies a message type of the first event message, queries whether a second process associated with the message type exists in a pre-stored registry, determines whether the message type of the second process stored in the registry is the same as the message type of the first event message if the second process exists, and if the second process does not exist, generates a second event message after the message type of the second process covers the message type of the first event message, and sends the second event message to the second process. When the cross-process communication is carried out, the cross-process communication center process is started to serve as an intermediate carrier of the inter-process communication, so that the multi-process communication efficiency can be improved, and the development cost can be reduced.
Referring to fig. 3, another flow chart of a cross-process communication method is provided according to an embodiment of the present application. The cross-process communication method can comprise the following steps:
s301, after the cross-process communication center process is started, creating a message queue file and distributing a message queue identifier for the message queue file.
Generally, the message queue file is a professional message middleware file for cloud formal business based on a high-availability distributed cluster technology, can provide asynchronous decoupling and peak and valley clipping capabilities for a distributed application system, and has the characteristics of massive message accumulation, high throughput, reliable retry and the like required by internet application. After each time of starting the cross-process communication center process, in order to prevent an error when the previous message queue file is not deleted as usual, the cross-process communication center process needs to delete the previous message queue file, then create the message queue file and allocate a message queue identifier to the message queue file, for example: the message queue file name is/tmp/mq _ ipc _ center and the message queue is identified as 32768.
S302, setting the message type monitored by the message queue file as a full message type.
Generally, the full message type indicates that the message queue file is used to store all event messages sent to the cross-process communication center process, and after the cross-process communication center process creates the message queue file and allocates the message queue identifier to the message queue file, the message type monitored by the message queue file needs to be set to be the full message type, for example: setting msg _ type of the monitored message types to be 0, all message types sent to the cross-process communication center process by the operating system can be received.
S303, when the event message monitored by the cross-process communication center process is a preset message type, analyzing the monitored event message to obtain a corresponding process name and an event type.
Generally, after monitoring an event message, a cross-process communication center process first needs to determine a message type of the event message, for example: analyzing the event message, acquiring a message header, determining a message type, determining the message type as a preset message type when the message type is IPC _ CENTER _ REGISTOR _ MQ, and then analyzing the monitored event message to obtain a corresponding process name and an event type, for example: 1025, determining the process name as the Remote control Remote process, the event type as 1024 key click message type and 1 real-time message transmission RTMP message type.
S304, acquiring the target message queue identification according to the process name, and recording the registration information into a registry to complete registration.
Generally, the target message queue identifier is an identifier of a message queue corresponding to a process that sends the monitored event message, and the registration information includes the process name, the event type, and the target message queue identifier. Determining the process name by the cross-process communication center process, splicing the process name and a preset keyword to obtain a target message queue file name, and acquiring a target message queue identifier based on the target message queue file name, for example: and determining that the process name is Remote, and setting the preset keyword as/tmp, so that the corresponding message queue file name is Remote/tmp, and the corresponding target message queue identifier 52234 can be obtained through the message queue file name.
S305, receiving a query request message from the source process.
Generally, the query request carries a message queue identifier and a first query identifier of a target process, the monitoring event type registered in the registry by the source process is a first event type, and a cross-process communication center process receives a query request message in a JSON format from the source process.
S306, sending the query request message to the target process.
Generally, the cross-process communication center process analyzes the query request message to determine a message queue identifier of a target process, sends the query request message to a message queue file of the target process corresponding to the message queue identifier of the target process, and enqueues the query request message according to the specification of a message queue format.
S307, receiving a query response message from the target process.
Generally, the query response message carries the first query identifier and the first event type, and after the cross-process communication center process sends the query request message to the target process, the cross-process communication center process waits for a query duration and then receives a query response message from the target process.
S308, sending the query response message to the source process.
Generally, the cross-process communication center process analyzes the query request message to determine a message queue identifier of a source process, and sends the query response message to a message queue file of the target process corresponding to the message queue identifier of the source process, where the query response message is queued based on a First-in-First-out (FIFO) policy.
When the scheme of the embodiment of the application is executed, after a process of a cross-process communication center is started, a message queue file is created and a message queue identifier is distributed for the message queue file, the message type monitored by the message queue file is set to be a full message type, when the event message monitored by the process of the cross-process communication center is a preset message type, the monitored event message is analyzed to obtain a corresponding process name and an event type, a target message queue identifier is obtained according to the process name, registration information is recorded in a registry to complete registration, a query request message from a source process is received, the query request message is sent to the target process, and a query response message from the target process is received. When the cross-process communication is carried out, the cross-process communication center process is started to serve as an intermediate carrier of the inter-process communication, so that the multi-process communication efficiency can be improved, and the development cost can be reduced.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 4, a schematic structural diagram of a cross-process communication apparatus provided in an exemplary embodiment of the present application is shown, which is hereinafter referred to as a communication apparatus 4. The communication means 4 may be implemented as all or part of a terminal by software, hardware or a combination of both. The method comprises the following steps:
a receiving module 401, configured to receive a first event message from a first process;
an identifying module 402 for identifying a message type of the first event message;
a query module 403, configured to query whether a second process associated with the message type exists in a pre-stored registry;
a determining module 404, configured to determine whether the message type of the second process stored in the registry is the same as the message type of the first event message;
a generating module 405, configured to generate a second event message after the message type of the second process is covered with the message type of the first event message if the first event message is not the first event message;
a sending module 406, configured to send the second event message to the second process.
Optionally, the receiving module 401 further includes:
the system comprises a registration unit, a message queue file generation unit and a message queue identification unit, wherein the registration unit is used for creating a message queue file and distributing a message queue identification to the message queue file after a cross-process communication center process is started; setting the message type monitored by the message queue file as a full message type; wherein, the full message type represents that the message queue file is used for storing all event messages sent to the cross-process communication center process; when the event message monitored by the cross-process communication center process is a preset message type, analyzing the monitored event message to obtain a corresponding process name and an event type; acquiring a target message queue identifier according to the process name; the target message queue identifier is an identifier of a message queue corresponding to a process which sends the monitored event message; recording the registration information into a registry to complete registration; wherein the registration information includes the process name, the event type, and the target message queue identifier.
The splicing unit is used for determining the process name; splicing the process name and a preset keyword to obtain a target message queue file name; and acquiring a target message queue identifier based on the target message queue file name.
The query unit is used for receiving a query request message from a source process; the query request carries a message queue identifier and a first query identifier of a target process, and the type of a monitoring event registered in the registry by the source process is a first event type; sending the query request message to the target process; receiving a query response message from the target process; wherein the query response message carries the first query identifier and the first event type; and sending the query response message to the source process.
Optionally, the sending module 406 further includes:
a transmission unit, configured to send the first event message to the second process when the message type of the second process is the same as the message type of the first event message; acquiring a message queue identifier of the second process in the registry; and sending the second event message to a message queue indicated by the message queue identification of the second process.
The embodiment of the present application and the method embodiments of fig. 2 to 3 are based on the same concept, and the technical effects brought by the embodiment are also the same, and the specific process may refer to the description of the method embodiments of fig. 2 to 3, and will not be described again here.
The device 4 may be a field-programmable gate array (FPGA), an application-specific integrated chip, a system on chip (SoC), a Central Processing Unit (CPU), a Network Processor (NP), a digital signal processing circuit, a Micro Controller Unit (MCU), or a Programmable Logic Device (PLD) or other integrated chips.
When the scheme of the embodiment of the application is executed, after a process of a cross-process communication center is started, a message queue file is created and a message queue identifier is distributed for the message queue file, the message type monitored by the message queue file is set to be a full message type, when the event message monitored by the process of the cross-process communication center is a preset message type, the monitored event message is analyzed to obtain a corresponding process name and an event type, a target message queue identifier is obtained according to the process name, registration information is recorded in a registry to complete registration, a query request message from a source process is received, the query request message is sent to the target process, and a query response message from the target process is received. When the cross-process communication is carried out, the cross-process communication center process is started to serve as an intermediate carrier of the inter-process communication, so that the multi-process communication efficiency can be improved, and the development cost can be reduced.
In the following method embodiments, for convenience of description, only the execution subject of each step is described as a computer capable of running a source process.
The cross-process query method provided in the embodiment of the present application will be described in detail below with reference to fig. 5.
Referring to fig. 5, a first flowchart of a cross-process query method is provided according to an embodiment of the present application. The method may comprise the steps of:
s501, generating an inquiry request message.
Generally, a source process refers to an event initiating process of inter-process communication, and first, the source process receives a cross-process communication message instruction, and generates a query request message according to the message instruction, where the query request carries a message queue identifier and a first query identifier of a target process, for example: the message queue is identified as 32768 and the first query is identified as 1001253. For example: the source process is an interface display process, and the query request message is a real-time traffic consumption query and is used for displaying on a display interface.
S502, registering the listening event type as a first event type in a registry.
Generally, a source process creates a message queue file and allocates a message queue identifier to the message queue file, and sets a message type monitored by the message queue file to be a first event type, for example: calling back the message type and the like, determining the registration information, recording the registration information into a registry to complete registration, wherein the registration information is registered by using a Map data format.
S503, sending the query request message to the target process through the cross-process communication center process.
Generally, after the source process converts the query request message into JSON format, the query request message is sent to the target process through a cross-process communication center process, and target detection refers to an event response process of inter-process communication, for example: the target detection is a network transmission management process and is used for detecting and controlling the real-time network transmission data volume. In one embodiment, the source process identifies a query mode of the query request message, and calls a synchronous query interface when the query mode is synchronous query, where parameters of the synchronous query interface provide a message type, a query condition, and a function address to be run after query completion, for example: flow consumption inquiry, card number, callback function address and the like, then setting an event lock for the source process, wherein the event lock sets timeout duration, and sends the inquiry request to the target process through a cross-process communication center process through the synchronous inquiry interface, wherein the receiving of the inquiry response message from the target process comprises: analyzing the query response message to determine the first query identifier, querying in the registry whether the first event type associated with the first query identifier exists, if not, discarding the query response message, determining a callback address in the registry, deleting a callback registration record to receive an asynchronous query, and if so, unlocking the event lock when the query duration does not exceed the timeout duration, for example: and encapsulating the query response message into a preset protocol structure body to be called into the callback function, wherein the subsequent logic of the source process can directly use the data under the callback function address to complete the subsequent logic processing, and if the subsequent logic processing is overtime, returning an overtime failure instruction.
In one embodiment, the source process identifies a query mode of the query request message, and invokes an asynchronous query interface when the query mode is asynchronous query, where parameters of the asynchronous query interface provide a message type, a query condition, and a function address to be executed after query completion, for example: and the flow consumption query, the card number, the callback function address and the like, recording the first query identifier in the registry, and sending the query request to the target process through the cross-process communication center process through the asynchronous query interface.
S504, receiving a query response message returned by the target process through the cross-process communication center process.
Generally, the source process sends the query request message to the target process through a cross-process communication center process, and receives a query response message returned by the target process through the cross-process communication center process after waiting for a query time, where the query response message carries the first query identifier, and the query response message is the first event type.
And S505, analyzing the query response message to obtain a query result, and storing the query result into a corresponding message queue file.
Generally, after receiving a query response message returned by the target process through the cross-process communication center process, the source process analyzes the query response message to obtain a query result, stores the query result in a corresponding message queue file, and when storing the query result in the corresponding message queue file, the source process needs to satisfy a queue format write-in read rule. For example: and during synchronous query, the source process encapsulates the query response message into a preset protocol structure body to be called into the callback function, executes the callback function, closes the waiting page and finishes displaying the consumption flow data.
According to the content, a source process generates a query request message, a monitoring event type is registered in a registry as a first event type, the query request message is sent to a target process through a cross-process communication center process, a query response message returned by the target process through the cross-process communication center process is received, the query response message is analyzed to obtain a query result, and the query result is stored in a corresponding message queue file. When the cross-process query is carried out, the source process sends the query request message to the target process through the cross-process communication center process, so that the communication efficiency among multiple processes can be improved, and the development cost is reduced.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 6, a schematic diagram of a second structure of a cross-process query apparatus according to an exemplary embodiment of the present application is shown, which is hereinafter referred to as a query apparatus 6 for short. The querying means 6 may be implemented as all or part of the terminal by software, hardware or a combination of both. The method comprises the following steps:
a generating module 601, configured to generate a query request message; the query request carries a message queue identifier and a first query identifier of a target process;
a registering module 602, configured to register the listening event type as a first event type in a registry;
a sending module 603, configured to send the query request message to the target process through a cross-process communication center process;
a receiving module 604, configured to receive a query response message returned by the target process through the cross-process communication center process; wherein the query response message carries the first query identifier, and the query response message is the first event type;
and the analyzing module 605 is configured to analyze the query response message to obtain a query result, and store the query result in a corresponding message queue file.
Optionally, the sending module 603 further includes:
the calling unit is used for identifying the query mode of the query request message; when the query mode is synchronous query, calling a synchronous query interface; setting an event lock for the source process; wherein the event lock sets a timeout duration; sending the query request to the target process through a cross-process communication center process through the synchronous query interface; wherein the receiving a query response message from the target process comprises: analyzing the query response message to determine the first query identifier; querying the registry for the presence of the first event type associated with the first query identity; if so, unlocking the event lock when the query duration does not exceed the timeout duration.
The embodiment of the present application and the embodiment of the method in fig. 5 are based on the same concept, and the technical effects brought by the embodiment are also the same, and the specific process may refer to the description of the embodiment of the method in fig. 5, and will not be described again here.
The device 6 may be a field-programmable gate array (FPGA), an application-specific integrated chip, a system on chip (SoC), a Central Processing Unit (CPU), a Network Processor (NP), a digital signal processing circuit, a Micro Controller Unit (MCU), or a Programmable Logic Device (PLD) or other integrated chips.
When the scheme of the embodiment of the application is executed, a source process generates a query request message, a monitoring event type is registered as a first event type in a registry, the query request message is sent to a target process through a cross-process communication center process, a query response message returned by the target process through the cross-process communication center process is received, the query response message is analyzed to obtain a query result, and the query result is stored in a corresponding message queue file. When the cross-process query is carried out, the source process sends the query request message to the target process through the cross-process communication center process, so that the communication efficiency among multiple processes can be improved, and the development cost is reduced.
In the following method embodiments, for convenience of description, only the execution subject of each step is described as a computer capable of running a target process.
The cross-process query method provided by the embodiment of the present application will be described in detail below with reference to fig. 7.
Referring to fig. 7, a second flow chart of a cross-process query method is provided according to an embodiment of the present application. The method may comprise the steps of:
s701, receiving a query request message sent by a source process through a cross-process communication center process.
Generally, object detection refers to event responsive processes of interprocess communication, such as: the target detection is a network transmission management process and the like, and the target process receives a query request message sent by a source process through a cross-process communication center process, such as: the source process is an interface display process, the query request message is a real-time traffic consumption query, and the target process is a network transmission management process. The query request carries a message queue identifier and a first query identifier of a target process.
S702, executing inquiry according to the inquiry request message to obtain an inquiry result.
Generally, after receiving a query request message sent by a cross-process communication center process from a source process, a target process analyzes the query request message, determines a query instruction, and executes a query based on the query instruction to obtain a query result.
And S703, generating a query response message based on the query result.
Generally, the query response message carries the first query identifier, and the query response message is the first event type. For example: after the target process obtains the query result, the query result is set as the callback message type, and the message identifier of the query result is set as the first query identifier 1001253.
S704, sending the query response message to the source process through the cross-process communication center process.
Generally, after the target process generates the query response message based on the query result, the query response message is converted into the JSON format, and the query response message is sent to the source process through the cross-process communication center process, for example: and the target process is a network transmission management process and sends the real-time traffic consumption query result to a source process interface display process through the cross-process communication center process, and the interface display process is used for displaying the real-time traffic consumption condition on the interface.
According to the content, the target process receives the query request message sent by the source process through the cross-process communication center process, executes query according to the query request message to obtain a query result, generates a query response message based on the query result, and sends the query response message to the source process through the cross-process communication center process. When the cross-process query is carried out, the target process receives the query request message from the source process through the cross-process communication center process, so that the communication efficiency among multiple processes can be improved, and the development cost is reduced.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 8, a schematic diagram of a third structure of a cross-process query device according to an exemplary embodiment of the present application is shown, which is hereinafter referred to as a query device 8. The querying means 8 may be implemented as all or part of the terminal by software, hardware or a combination of both. The method comprises the following steps:
a receiving module 801, configured to receive a query request message sent by a source process through a cross-process communication center process; the query request carries a message queue identifier and a first query identifier of a target process;
a query module 802, configured to execute a query according to the query request message to obtain a query result;
a generating module 803, configured to generate a query response message based on the query result; the query response message carries the first query identifier, and the query response message is the first event type;
a sending module 804, configured to send the query response message to the source process through the cross-process communication center process.
The embodiment of the present application and the embodiment of the method in fig. 7 are based on the same concept, and the technical effects brought by the embodiment are also the same, and the specific process may refer to the description of the embodiment of the method in fig. 7, and will not be described again here.
The device 8 may be a field-programmable gate array (FPGA), an application-specific integrated chip, a system on chip (SoC), a Central Processing Unit (CPU), a Network Processor (NP), a digital signal processing circuit, a Micro Controller Unit (MCU), or a Programmable Logic Device (PLD) or other integrated chips.
When the scheme of the embodiment of the application is executed, a target process receives a query request message sent by a source process through a cross-process communication center process, executes query according to the query request message to obtain a query result, generates a query response message based on the query result, and sends the query response message to the source process through the cross-process communication center process. When the cross-process query is carried out, the target process receives the query request message from the source process through the cross-process communication center process, so that the communication efficiency among multiple processes can be improved, and the development cost is reduced.
An embodiment of the present application further provides a computer storage medium, where the computer storage medium may store a plurality of instructions, where the instructions are suitable for being loaded by a processor and performing the above method steps, and a specific execution process may refer to specific descriptions of the embodiments shown in fig. 2 or fig. 3 or fig. 5 or fig. 7, which are not described herein again.
The present application further provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the template control method according to the above embodiments.
Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 9, the electronic device 9 may include: at least one processor 901, at least one network interface 904, a user interface 903, memory 905, at least one communication bus 902.
Wherein a communication bus 902 is used to enable connective communication between these components.
The user interface 903 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 903 may also include a standard wired interface and a wireless interface.
The network interface 904 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
Processor 901 may include one or more processing cores, among other things. The processor 901 interfaces with various components throughout the terminal 900 using various interfaces and lines to perform various functions and process data for the terminal 900 by executing or performing instructions, programs, code sets, or instruction sets stored in the memory 905, as well as invoking data stored in the memory 905. Optionally, the processor 901 may be implemented in at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 501 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 901, but may be implemented by a single chip.
The Memory 905 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 905 includes a non-transitory computer-readable medium. The memory 905 may be used to store instructions, programs, code, sets of codes, or sets of instructions. The memory 905 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the above-described method embodiments, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory 905 may optionally be at least one memory device located remotely from the processor 901. As shown in fig. 9, the memory 905, which is a type of computer storage medium, can include an operating system, a network communication module, a user interface module, and a cross-process communication application program therein.
In the electronic device 900 shown in fig. 9, the user interface 903 is mainly used as an interface for providing input for a user, and acquiring data input by the user.
The first embodiment is as follows:
when the electronic device is a computer capable of running a cross-process communication center process, the processor 901 may be configured to invoke a cross-process communication application stored in the memory 905, and specifically perform the following operations:
receiving a first event message from a first process;
identifying a message type of the first event message;
querying whether a second process associated with the message type exists in a pre-stored registry;
if yes, judging whether the message type of the second process stored in the registry is the same as the message type of the first event message;
if not, generating a second event message after covering the message type of the first event message with the message type of the second process;
and sending the second event message to the second process.
In one embodiment, before processor 901 performs the receiving the first event message from the first process, it further includes:
after the cross-process communication center process is started, creating a message queue file and distributing a message queue identifier for the message queue file;
setting the message type monitored by the message queue file as a full message type; wherein, the full message type represents that the message queue file is used for storing all event messages sent to the cross-process communication center process;
when the event message monitored by the cross-process communication center process is a preset message type, analyzing the monitored event message to obtain a corresponding process name and an event type;
acquiring a target message queue identifier according to the process name; the target message queue identifier is an identifier of a message queue corresponding to a process which sends the monitored event message;
recording the registration information into a registry to complete registration; wherein the registration information includes the process name, the event type, and the target message queue identification.
In one embodiment, processor 901 performs the operations further comprising:
and when the message type of the second process is the same as the message type of the first event message, sending the first event message to the second process.
In one embodiment, the processor 901 performs the acquiring of the target message queue identifier according to the process name, including:
determining the process name;
splicing the process name and a preset keyword to obtain a target message queue file name;
and acquiring a target message queue identifier based on the target message queue file name.
In one embodiment, processor 901 performs the sending the second event message to the second process, including:
acquiring a message queue identifier of the second process in the registry;
and sending the second event message to a message queue indicated by the message queue identification of the second process.
In one embodiment, after the recording the registration information to the registry is completed, the processor 901 further includes:
receiving a query request message from a source process; the query request carries a message queue identifier and a first query identifier of a target process, and the type of a monitoring event registered in the registry by the source process is a first event type;
sending the query request message to the target process;
receiving a query response message from the target process; wherein the query response message carries the first query identifier and the first event type;
and sending the query response message to the source process.
Example two:
when the electronic device is a computer capable of running a source process, the processor 901 may be configured to invoke a cross-process query application stored in the memory 905, and specifically perform the following operations:
generating a query request message; the query request carries a message queue identifier and a first query identifier of a target process;
registering the monitoring event type as a first event type in a registry;
sending the query request message to the target process through a cross-process communication center process;
receiving a query response message returned by the target process through the cross-process communication center process; wherein the query response message carries the first query identifier, and the query response message is the first event type;
and analyzing the query response message to obtain a query result, and storing the query result into a corresponding message queue file.
In one embodiment, the sending of the query request message to the target process through the inter-process communication center process by the processor 901 includes:
identifying a query mode of the query request message;
when the query mode is synchronous query, calling a synchronous query interface;
setting an event lock for the source process; wherein the event lock sets a timeout duration;
sending the query request to the target process through a cross-process communication center process through the synchronous query interface;
wherein the receiving a query response message from the target process comprises:
analyzing the query response message to determine the first query identifier;
querying the registry for the presence of the first event type associated with the first query identity;
if so, unlocking the event lock when the query duration does not exceed the timeout duration.
In one embodiment, the processor 901 performs the sending of the query request message to the target process through the inter-process communication center process, including:
identifying a query mode of the query request message;
when the query mode is asynchronous query, calling an asynchronous query interface;
recording the first query identity in the registry;
and sending the query request to the target process through a cross-process communication center process through the asynchronous query interface.
Example three:
when the electronic device is a computer capable of running a target process, the processor 901 may be configured to invoke a cross-process query application stored in the memory 905, and specifically perform the following operations:
receiving a query request message sent by a source process through a cross-process communication center process; the query request carries a message queue identifier and a first query identifier of a target process;
executing query according to the query request message to obtain a query result;
generating a query response message based on the query result; the query response message carries the first query identifier, and the query response message is the first event type;
and sending the query response message to the source process through the cross-process communication center process.
The technical concept of the embodiment of the present application is the same as that of fig. 2, 3, 5, or 7, and the specific process may refer to the method embodiment of fig. 2, 3, 5, or 7, which is not described herein again.
In the embodiment of the application, a cross-process communication center process receives a first event message from a first process, identifies a message type of the first event message, queries whether a second process associated with the message type exists in a pre-stored registry, if so, judges whether the message type of the second process stored in the registry is the same as the message type of the first event message, if not, generates a second event message after covering the message type of the first event message with the message type of the second process, and sends the second event message to the second process. When the cross-process communication is carried out, the cross-process communication center process is started to serve as an intermediate carrier of the inter-process communication, so that the multi-process communication efficiency can be improved, and the development cost can be reduced.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory or a random access memory.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (10)

1. A method of cross-process communication, the method comprising:
receiving a first event message from a first process;
identifying a message type of the first event message;
querying whether a second process associated with the message type exists in a pre-stored registry;
if yes, judging whether the message type of the second process stored in the registry is the same as the message type of the first event message;
if not, generating a second event message after covering the message type of the first event message with the message type of the second process;
and sending the second event message to the second process.
2. The method of claim 1, wherein before receiving the first event message from the first process, further comprising:
after the cross-process communication center process is started, creating a message queue file and distributing a message queue identifier for the message queue file;
setting the message type monitored by the message queue file as a full message type; wherein, the full message type represents that the message queue file is used for storing all event messages sent to the cross-process communication center process;
when the event message monitored by the cross-process communication center process is a preset message type, analyzing the monitored event message to obtain a corresponding process name and an event type;
acquiring a target message queue identifier according to the process name; the target message queue identifier is an identifier of a message queue corresponding to a process which sends the monitored event message;
recording the registration information into a registry to complete registration; wherein the registration information includes the process name, the event type, and the target message queue identification.
3. The method of claim 1, further comprising:
and when the message type of the second process is the same as the message type of the first event message, sending the first event message to the second process.
4. The method of claim 2, wherein obtaining the target message queue id according to the process name comprises:
determining the process name;
splicing the process name and a preset keyword to obtain a target message queue file name;
and acquiring a target message queue identifier based on the target message queue file name.
5. The method of claim 1, wherein sending the second event message to the second process comprises:
acquiring a message queue identifier of the second process in the registry;
and sending the second event message to a message queue indicated by the message queue identification of the second process.
6. The method of claim 1, wherein the format of the first event message is an object notation JSON format.
7. The method of claim 2, wherein after the registering the registration information to the registry, further comprising:
receiving a query request message from a source process; the query request carries a message queue identifier and a first query identifier of a target process, and the monitoring event type registered by the source process in the registry is a first event type;
sending the query request message to the target process;
receiving a query response message from the target process; wherein the query response message carries the first query identifier and the first event type;
and sending the query response message to the source process.
8. A cross-process communication apparatus, comprising:
a receiving module for receiving a first event message from a first process;
an identification module for identifying a message type of the first event message;
the query module is used for querying whether a second process associated with the message type exists in a pre-stored registry;
a judging module, configured to judge whether the message type of the second process stored in the registry is the same as the message type of the first event message if the first event message exists;
if not, the generation module is used for generating a second event message after covering the message type of the first event message with the message type of the second process;
and the sending module is used for sending the second event message to the second process.
9. A computer storage medium, characterized in that it stores a plurality of instructions adapted to be loaded by a processor and to carry out the method steps according to any one of claims 1 to 7.
10. An electronic device, comprising: a memory and a processor; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the method steps according to any of claims 1 to 7.
CN202011393241.9A 2020-12-02 2020-12-02 Cross-process communication method and device, storage medium and electronic equipment Pending CN114579327A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011393241.9A CN114579327A (en) 2020-12-02 2020-12-02 Cross-process communication method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011393241.9A CN114579327A (en) 2020-12-02 2020-12-02 Cross-process communication method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN114579327A true CN114579327A (en) 2022-06-03

Family

ID=81770686

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011393241.9A Pending CN114579327A (en) 2020-12-02 2020-12-02 Cross-process communication method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN114579327A (en)

Similar Documents

Publication Publication Date Title
CN109213611B (en) Cross-process communication method, device, terminal and storage medium
US20070011291A1 (en) Grid automation bus to integrate management frameworks for dynamic grid management
EP3614250A1 (en) Data processing method and electronic device
US11853767B2 (en) Inter-core data processing method, system on chip and electronic device
TW200404225A (en) Dynamic wizard interface system and method
CN110413822B (en) Offline image structured analysis method, device and system and storage medium
CN112313627B (en) Mapping mechanism of event to serverless function workflow instance
CN111737022A (en) Interface calling method, system, equipment and medium based on micro-service
CN112100090A (en) Data access request processing method, device, medium and memory mapping controller
US10574765B2 (en) Method, device, and non-transitory computer-readable recording medium
CN112764563A (en) Multi-screen control method, device and system, electronic equipment and storage medium
CN111679911A (en) Management method, device, equipment and medium for GPU (graphics processing Unit) card in cloud environment
WO2022188614A1 (en) Apparatus, method and system for monitoring image forming apparatus, and storage medium
CN111611065A (en) Calling method and device of machine learning algorithm, storage medium and electronic equipment
CN114040189A (en) Multimedia test method, device, storage medium and electronic equipment
WO2023193633A1 (en) Image analysis methods and apparatuses, computer device and storage medium
CN110245027B (en) Inter-process communication method and device
CN114579327A (en) Cross-process communication method and device, storage medium and electronic equipment
CN115237481A (en) Method, device and equipment for driving external equipment and storage medium
CN115599268A (en) Screen capture method, computing device and storage medium
CN114064429A (en) Audit log acquisition method and device, storage medium and server
US10360701B2 (en) Integrated visualization
CN113852610A (en) Message processing method and device, computer equipment and storage medium
CN112231290A (en) Method, device and equipment for processing local log and storage medium
CN112631812A (en) Identification setting method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination