Inter-process communication device, inter-process communication method, and inter-process communication program
The inter-process communication device addresses communication bottlenecks and failures by using a destination file system for direct communication, reducing background communication and eliminating data relaying in Pub-Sub systems.
Patent Information
- Application Number
- JP2021011583
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2021-01-28
- Publication Date
- 2024-11-11
- Estimated Expiration
- 2041-01-28
AI Technical Summary
Existing Pub-Sub communication methods face issues such as communication bottlenecks and failures due to broker abnormalities, and excessive background communication in dynamic networks, which can interfere with intended data transmission.
An inter-process communication device that uses a destination file system to specify receiving process destinations within topic directories, allowing direct communication without brokers and reducing background communication.
This approach minimizes background communication and eliminates data relaying, ensuring stable Pub-Sub communication even with varying process numbers and avoiding communication failures.
Smart Images

Figure 0007580284000001 
Figure 0007580284000002 
Figure 0007580284000003
Abstract
Description
[Technical field]
[0001] The present invention relates to an inter-process communication device, an inter-process communication method, and an inter-process communication program for performing communication between processes. [Background technology]
[0002] In recent years, a communication technique called Pub-Sub communication (publish-subscribe communication) is used in inter-process communication, as shown in FIG. 4. This Pub-Sub communication is a communication in which a sending process (publisher) 101b sends a message without specifying a specific receiving process (subscriber) 101a. That is, Pub-Sub communication is a technique that enables the configuration of a dynamic network (many-to-many communication) in which the receiving process 101a and the sending process 101b are not directly connected (the communication partner is not directly specified) by connecting the receiving process 101a and the sending process 101b via an intermediary called a topic 102. FIG. 4 shows a case in which communication is performed between three receiving processes 101a-1 to 101a-3 and two sending processes 101b-1 and 101b-2. The topic 102 can be a class of messages to be sent or received, for example, a character string called a topic name.
[0003] Known methods for implementing this Pub-Sub communication include a method that uses an intermediary program (communication control process) called a broker (see, for example, Patent Document 1), and a method that does not use a broker, called a distributed type (see, for example, Patent Document 2).
[0004] First, a method for using a broker will be described with reference to FIG. The broker 103 is a program that operates independently of the programs that perform communication, and the communication using process 101 (the receiving process 101 a and the sending process 101 b ) transmits and receives data via the broker 103 . Specifically, first, the receiving process 101a registers the topic 102 to be received in the broker 103. Then, the sending process 101b sends data specifying the topic 102 to the broker 103. Then, upon receiving the data, the broker 103 realizes Pub-Sub communication by forwarding the data to all receiving processes 101a that request subscription to the topic 102 according to the topic 102 to which the data belongs. In other words, Pub-Sub communication is achieved by the broker 103 relaying the data.
[0005] Next, the distributed type will be described with reference to FIG. In this distributed system, all communication use processes 101 periodically notify each other of information related to the topics 102 they are sending and receiving, and update the information, thereby realizing the sending and receiving of messages required for each topic 102. Specifically, first, communication using processes 101 exchange information about the topic 102 that they periodically send and receive using background communication called discovery communication or the like. Then, when the sending process 101b sends data, it sends the same data, collected in the background communication, to all receiving processes 101a that want to receive the topic 102 to be sent, thereby achieving Pub-Sub communication. The thick arrow in Figure 6 indicates background communication by the receiving process 101a-1. [Prior art documents] [Patent documents]
[0006] [Patent Document 1] JP 2020-017118 A [Patent Document 2] JP 2015-043208 A Summary of the Invention [Problem to be solved by the invention]
[0007] However, in the method using a broker, if the broker stops due to an abnormality, all communication becomes impossible. Also, if there are a large number of sending and receiving processes, the load on the broker program becomes high, and this may cause a bottleneck in communication.
[0008] In addition, in the distributed model, Pub-Sub communication is a dynamic network, so information needs to be exchanged frequently in case the programs that send and receive topics are started and stopped, and as the number of sending and receiving processes increases, a large amount of background communication occurs. This background communication is communication other than messages, so there is a possibility that it may interfere with (put on hold) the communication of data that you actually want to send and receive.
[0009] The present invention has been made to solve the above-mentioned problems, and has an object to provide an inter-process communication device that can reduce background communication and does not require data relay, as compared to the conventional device. [Means for solving the problem]
[0010] The inter-process communication device of the present invention is characterized in that it comprises a receiving process that generates a destination file indicating its own destination in a topic directory corresponding to a topic to be received among topic directories provided for each topic in a communication directory, and a sending process that identifies a destination from the destination file created in the topic directory corresponding to a topic to be sent among the topic directories, and transmits data to the destination. Effect of the Invention
[0011] According to the present invention, since it is configured as described above, it is possible to reduce background communication compared to the conventional art, and data relay is not required. [Brief description of the drawings]
[0012] [Figure 1]1 illustrates a configuration example and an operation example of an inter-process communication device according to a first embodiment; [Diagram 2] 11A and 11B are diagrams illustrating a configuration example and an operation example of an inter-process communication device according to a second embodiment. [Diagram 3] 11A and 11B are diagrams illustrating a configuration example and an operation example of an inter-process communication device according to a third embodiment. [Figure 4] FIG. 1 is a diagram illustrating conventional Pub-Sub communication. [Diagram 5] FIG. 1 is a diagram illustrating a conventional Pub-Sub communication using a broker. [Figure 6] FIG. 1 is a diagram illustrating conventional distributed Pub-Sub communication. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0013] Hereinafter, an embodiment of the present invention will be described in detail with reference to the drawings. Embodiment 1 FIG. 1 is a diagram showing an example of the configuration and operation of an inter-process communication device according to the first embodiment. The inter-process communication device according to the first embodiment includes one or more receiving processes (receiving programs) 1a and one or more sending processes (sending programs) 1b, as shown in Fig. 1. Three receiving processes 1a-1 to 1a-3 and three sending processes 1b-1 to 1b-3 are shown in Fig. 1. In the following description, the receiving process 1a and the sending process 1b may be collectively referred to as a communication using process 1.
[0014] The inter-process communication device is a computer realized by a CPU (Central Processing Unit) or the like that executes a program stored in a memory or the like.
[0015] The inter-process communication device is provided with a communication directory (communication working directory) 11. The communication directory 11 is a directory or folder used for communication.
[0016] Furthermore, a topic directory 12 is prepared for each topic in the communication directory 11. The topic directory 12 is a directory of names that allow the topics to be distinguished from one another, such as the names of topics to be used.
[0017] 1 shows a case where two topic directories 12-1 and 12-2 are prepared in a communication directory 11. The topic directory 12-1 is a topic directory corresponding to a first topic, and the topic directory 12-2 is a topic directory corresponding to a second topic.
[0018] In some cases, topics are classified into classes with a hierarchical structure, for example with a prefix called a namespace. In such cases, the directory structure can be made hierarchical.
[0019] Furthermore, the topic directory 12 may be configured so that the communication using process 1 (the receiving process 1a or the sending process 1b) generates the topic directory 12 as necessary. The location where the topic directory 12 is generated needs only to point to the same location for the receiving process 1a and the sending process 1b. Therefore, for example, an existing directory that is automatically created by the operating system (Windows (registered trademark) or Linux (registered trademark), etc.) may be specified in the program.
[0020] When the receiving process 1a starts its own program, it creates a destination file 13 in a specified format in the topic directory 12 that corresponds to the topic to be received, among the topic directories 12 provided in the communication directory 11. The destination file 13 is a file that indicates its own destination (communication path).
[0021] When the receiving process 1a uses socket communication for the destination, it may describe the IP address and port number in the destination file 13, or the name of the destination file 13 itself may indicate the IP address and port number. When the receiving process 1a uses named pipe communication or UNIX domain socket communication in a UNIX (registered trademark) system, it may directly generate the destination file 13 that serves as the communication path. In other words, the receiving process 1a may generate the destination file 13 in a form that suits the communication format to be used.
[0022] In addition, there is a possibility that multiple receiving processes 1a may receive from one topic. Therefore, in the inter-process communication device, it is necessary to make an arrangement so that the name of the destination file 13 is not duplicated.
[0023] In Fig. 1, the receiving processes 1a-1 and 1a-2 receive messages from a first topic, and the receiving process 1a-3 receives messages from a second topic. That is, in Fig. 1, a destination file 13-1 indicating the destination of the receiving process 1a-1 and a destination file 13-2 indicating the destination of the receiving process 1a-2 are generated in the topic directory 12-1. Also in Fig. 1, a destination file 13-3 indicating the destination of the receiving process 1a-3 is generated in the topic directory 12-2.
[0024] When the sending process 1b sends (distributes) a topic, it first identifies the destinations of all the receiving processes 1a from (a list of) destination files 13 created in the topic directory 12 corresponding to the topic to be sent, among the topic directories 12 provided in the communication directory 11. Then, the sending process 1b sends a message (data) to all the identified destinations.
[0025] FIG. 1 shows a case where the sending process 1b-1 and the sending process 1b-2 are targets of sending messages on a first topic, and the sending process 1b-3 is targets of sending messages on a second topic. In this case, the sending process 1b-1 identifies the destinations of the receiving processes 1a-1 and 1a-2 from the destination files 13-1 and 13-2 in the topic directory 12-1 corresponding to the first topic. Then, the sending process 1b-1 sends a message (data) to the identified destination. This allows the receiving processes 1a-1 and 1a-2 to receive the message from the sending process 1b-1. Similarly, the sending process 1b-2 identifies the destinations of the receiving processes 1a-1 and 1a-2 from the destination files 13-1 and 13-2 in the topic directory 12-1 corresponding to the first topic. Then, the sending process 1b-2 sends a message (data) to the identified destination. This allows the receiving processes 1a-1 and 1a-2 to receive the message from the sending process 1b-2. The sending process 1b-3 also identifies the destination of the receiving process 1a-3 from the destination file 13-3 in the topic directory 12-2 corresponding to the second topic. The sending process 1b-3 then transmits a message (data) to the identified destination. This allows the receiving process 1a-3 to receive the message from the sending process 1b-3.
[0026] When the receiving process 1a's program stops, it deletes the destination file 13 created in the topic directory 12. This prevents the sending process 1b from considering the inactive receiving process 1a as a communication destination. Therefore, the inter-process communication device retains the advantage of Pub-Sub communication, that is, the ability to configure a dynamic network without specifying a communication partner.
[0027] According to the above, the inter-process communication device according to the first embodiment uses a destination file system to enable the sending process 1b to specify the destination of the receiving process 1a that wants to receive a topic. As a result, the inter-process communication device does not require background communication for the communication using processes 1 to communicate the topics they need with each other. Moreover, in the inter-process communication device according to the first embodiment, the sending process 1b can identify the destination of the receiving process 1a to which the sending data is to be sent, and communication is performed directly between the sending process 1b and the receiving process 1a. Therefore, in this inter-process communication device, Pub-Sub communication is possible without requiring an intermediary program such as a broker. In other words, in this inter-process communication device, communication failure due to the stop of the broker does not occur.
[0028] As described above, according to this embodiment 1, the inter-process communication device includes a receiving process 1a that generates a destination file 13 indicating its own destination in a topic directory 12 corresponding to a topic to be received among topic directories 12 provided for each topic in communication directory 11, and a sending process 1b that identifies a destination from the destination file 13 created in the topic directory 12 corresponding to a topic to be sent among topic directories 12, and sends data to the destination. As a result, the inter-process communication device according to embodiment 1 can reduce background communication compared to conventional devices and does not require data relaying.
[0029] That is, the inter-process communication device according to the first embodiment can realize a Pub-Sub communication system that does not require frequent background communication and does not require data relay. Also, this inter-process communication device can realize a Pub-Sub communication system that has a small CPU load even if the number of communication using processes 1 increases and is capable of operation independent of a specific program operation. Furthermore, the inter-process communication device according to the first embodiment is applicable not only to Pub-Sub communication but also to communication systems that configure dynamic networks that do not specify a transmission destination, and provides the same effects as those described above.
[0030] Embodiment 2 Fig. 2 is a diagram showing an example of the configuration and operation of an inter-process communication device according to embodiment 2. The inter-process communication device according to embodiment 2 shown in Fig. 2 is obtained by adding a communication management process 2 to the inter-process communication device according to embodiment 1 shown in Fig. 1. Other configurations of the inter-process communication device according to embodiment 2 shown in Fig. 2 are similar to those of the inter-process communication device according to embodiment 1 shown in Fig. 1, and the same reference numerals are used and only the different parts will be described. Note that the communication directory 11 is not shown in Fig. 2.
[0031] The communication management process 2 manages communication between processes. This communication management process 2 is started and operates as a program separate from the communication using process 1.
[0032] When the communication management process 2 is notified of a topic and a data structure corresponding to that topic from the communication using process 1, it determines whether that topic is already being used by another communication using process 1. If the communication management process 2 determines that the notified topic is already being used by another communication using process 1, it determines whether the data structure corresponding to the topic already being used by the other communication using process 1 matches the notified data structure. If the communication management process 2 determines that the data structures match, it notifies the communication using process 1, which is the source of the notification, of communication permission. On the other hand, if the communication management process 2 determines that the data structures do not match, it notifies the communication using process 1, which is the source of the notification, of communication refusal.
[0033] The notification method by the communication management process 2 may use communication, or may take the form of accessing a specific location such as a shared memory or a shared file.
[0034] The communication directory 11 may be configured so that it is generated by the communication management process 2 .
[0035] When the receiving process 1a in the second embodiment starts its own program, it notifies the communication management process 2 of the topic to be received and the data structure corresponding to that topic (topic usage notification). The notification method by the receiving process 1a may use communication or may take the form of accessing a specific location such as a shared memory or a shared file.
[0036] When the receiving process 1a is notified of communication permission from the communication management process 2, the receiving process 1a generates a destination file 13 in a prescribed format in the topic directory 12 that corresponds to the topic to be received from among the topic directories 12. On the other hand, the receiving process 1a does not perform communication if a communication refusal is notified from the communication management process 2. That is, in this case, the receiving process 1a does not generate a destination file 13 in the topic directory 12 that corresponds to the topic to be received among the topic directories 12.
[0037] Furthermore, when the transmitting process 1b in the second embodiment starts its own program, it notifies the communication management process 2 of the topic to be transmitted and the data structure corresponding to that topic (topic usage notification). The notification method by the sending process 1b may use communication or may take the form of accessing a specific location such as a shared memory or a shared file.
[0038] Then, when the sending process 1b is notified of communication permission from the communication management process 2, when sending (distributing) a topic, it first identifies the destinations of all receiving processes 1a from (a list of) destination files 13 generated in the topic directory 12 corresponding to the topic to be sent among the topic directory 12. Then, the sending process 1b sends a message (data) to all the identified destinations. On the other hand, when the sending process 1b receives a communication refusal notice from the communication management process 2, the sending process 1b does not perform communication.
[0039] The example in Figure 2 shows a case in which a sending process 1b-1 notifies the communication management process 2 of a topic and data structure (notification shown by reference symbol 201a), a receiving process 1a-1 notifies the communication management process 2 of the same topic and data structure (notification shown by reference symbol 201a), and a receiving process 1a-2 notifies the communication management process 2 of a different topic and data structure (notification shown by reference symbol 201b). In this case, the communications management process 2 notifies the sending process 1b-1 and the receiving process 1a-1 of communications permission (notification indicated by reference numeral 202a), and notifies the receiving process 1a-2 of communications refusal (notification indicated by reference numeral 202b). As a result, the receiving process 1a-1 creates a destination file 13-1 in a specified format in the topic directory 12-1 and communicates with the sending process 1b-1. On the other hand, the receiving process 1a-2 does not communicate with the sending process 1b-1.
[0040] According to the above, by using a program that manages communications (communication management process 2), the data structures of the topics used in the communications can be matched, and it is possible to prevent the sending and receiving of communication data having a data structure different from the data structure assumed for each topic. This prevents communication errors, eliminates unnecessary communications, and is expected to reduce the amount of communications and the load on the CPU.
[0041] In the above description, only the data structure is used for the sake of clarity, but the information sent from the communication using process 1 to the communication management process 2 is not limited to the data structure and may include information necessary for managing Pub-Sub communication.
[0042] Furthermore, the notification from the communication management process 2 may include information necessary for communication management for the communication utilization process 1. For example, in a method using a destination file system, there is a possibility that the name of the destination file 13 may be duplicated, causing the destination file 13 to be overwritten and making communication impossible. However, this can be solved by using the communication management process 2. That is, when a permission response is made upon receiving a topic usage notification from the receiving process 1a, the communication management process 2 notifies the receiving process 1a of a name that does not overlap with the name of a destination file 13 created by the existing receiving process 1a. The receiving process 1a then creates a destination file 13 with the name notified by the communication management process 2. On the other hand, when a rejection response is made, the communication management process 2 does not notify the name of the destination file 13, thereby preventing the receiving process 1a from creating a destination file 13, thereby preventing unauthorized communication.
[0043] Also, the topic directory 12 may be generated by the communication management process 2, and the topic directory name may be generated after some conversion by the communication management process 2, and the converted topic directory name may be notified as an authorization response upon receiving a topic usage notification. This also makes it possible to prevent unauthorized communication.
[0044] Embodiment 3 In the first and second embodiments, the destination file system is used to prepare a destination file 13 indicating the destination of the receiving process 1a. On the other hand, if the receiving process 1a terminates abnormally while this destination file 13 is placed in the topic directory 12, the destination file 13 will not be deleted and will remain. In this case, when the sending process 1b sends data, it will also try to send data to the receiving process 1a that terminated abnormally. Here, we will explain a method to avoid this.
[0045] Fig. 3 is a diagram showing an example of the configuration and operation of an inter-process communication device according to embodiment 3. The inter-process communication device according to embodiment 3 shown in Fig. 3 adds a communication management process 2 to the inter-process communication device according to embodiment 1 shown in Fig. 1. Other configurations of the inter-process communication device according to embodiment 3 shown in Fig. 3 are similar to those of the inter-process communication device according to embodiment 1 shown in Fig. 1, so the same reference numerals are used and only the different parts will be described. Note that the communication directory 11 is not shown in Fig. 3.
[0046] The communication management process 2 manages communication between processes. The communication management process 2 runs as a separate program from the communication using process 1, and monitors the alive state of the communication using process 1. That is, the communication management process 2 holds the process information notified from the communication using process 1, and periodically checks the operation state of the communication using process 1 using the functions of the operating system.
[0047] When the communication management process 2 determines that the communication using process 1 has terminated abnormally, if the communication using process 1 is a receiving process 1a, it deletes the destination file 13 that was used by the receiving process 1a. This enables the communication management process 2 to prevent the sending process 1b from recognizing the abnormally terminated receiving process 1a as a destination.
[0048] When the receiving process 1a in the third embodiment starts its own program, it notifies the communication management process 2 of its own process information (for example, a process ID in the case of a UNIX-based operating system). At this time, the receiving process 1a also notifies the communication management process 2 of the destination file name of the destination file 13 to be used. Thereafter, the receiving process 1a periodically notifies the communication management process 2 of its own process information. Furthermore, when the receiving process 1a's program is stopped normally, it notifies the communication management process 2 of its process information and the communication stop. At this time, the receiving process 1a also deletes the destination file 13 before terminating the program.
[0049] Furthermore, the transmitting process 1b in the third embodiment notifies the communication management process 2 of its own process information (eg, a process ID in the case of a UNIX-based operating system) when its own program is started. Thereafter, the sending process 1b periodically notifies the communication management process 2 of its own process information. Furthermore, when the transmitting process 1b's own program is stopped normally, it notifies the communication management process 2 of the process information and the communication stop.
[0050] 3, the communication management process 2 monitors the alive status of the communication using processes 1-1 and 1-2 by receiving process information from the communication using processes 1-1 and 1-2. In this case, if the communication using process 1-2 terminates abnormally, the communication management process 2 deletes the destination file 13-2 indicating the destination of the receiving process 1a-2.
[0051] According to the above, by doing so, even if the receiving process 1a terminates abnormally, it is possible to prevent unnecessary communication operations from occurring, which is expected to reduce the amount of communication.
[0052] Furthermore, when the communication management process 2 is notified of the process information at the time of startup from the receiving process 1a, the receiving process 1a may be notified of the destination file name generated by the receiving process 1a. In this case, the receiving process 1a does not need to notify the communication management process 2 of the destination file name.
[0053] In the above, the above function is added to the inter-process communication device according to the first embodiment. However, the present invention is not limited to this, and the above function may be added to the inter-process communication device according to the second embodiment, and the same effect as above can be obtained.
[0054] It should be noted that, within the scope of the present invention, the embodiments may be freely combined, any component of each embodiment may be modified, or any component of each embodiment may be omitted. [Explanation of symbols]
[0055] 1. Communication Usage Process 1a Receiver process 1b Sender process 2. Communications Management Process 11 Communications Directory 12 Topic Directory 13 Destination File
Claims
1. a receiving process that generates a destination file indicating its own destination in a topic directory corresponding to a topic to be received, among topic directories provided for each topic in a communication directory; a sending process that identifies a destination from a destination file generated in a topic directory corresponding to a topic to be sent among the topic directories, and sends data to the destination; An inter-process communication device comprising:
2. a communication management process that detects an abnormal termination based on process information notified from the receiving process and the transmitting process, and deletes a destination file indicating the destination of the receiving process if the process that detected the abnormal termination is the receiving process; 2. The inter-process communication device according to claim 1.
3. a communication management process that, when a topic and a data structure corresponding to the topic are notified and it is determined that the data structure matches a data structure corresponding to the topic used in a process other than the process that is the notification source, notifies the notification source of communication permission; The receiving process notifies the communication management process of a topic to be received and a data structure corresponding to the topic, and when communication permission is received from the communication management process, creates a destination file in a topic directory; The sending process notifies the communication management process of the topic to be sent and the data structure corresponding to that topic, and when communication permission is received from the communication management process, identifies a destination from a destination file created in a topic directory and sends data to that destination.
2. The inter-process communication device according to claim 1.
4. The communication management process detects an abnormal termination based on process information notified from the receiving process and the transmitting process, and if the process that detected the abnormal termination is the receiving process, deletes a destination file that indicates the destination of the receiving process.
4. The inter-process communication device according to claim 3.
5. A receiving process generates a destination file indicating its own destination in a topic directory corresponding to a topic to be received, among topic directories provided for each topic in a communication directory; a sending process identifying a destination from a destination file generated in a topic directory corresponding to a topic to be sent among the topic directories, and sending data to the destination; The inter-process communication method includes:
6. A receiving process generates a destination file indicating its own destination in a topic directory corresponding to a topic to be received, among topic directories provided for each topic in a communication directory; a sending process identifying a destination from a destination file generated in a topic directory corresponding to a topic to be sent among the topic directories, and sending data to the destination; An inter-process communication program for executing the following on a computer.
Citation Information
Patent Citations
Communications device utilizing central discovery mechanism, and individual method
JP2015043208A
Information processing device and information processing program
JP2015230603A
Broker device, client device, communication system, communication method, and program
JP2020017118A
Information processing device, information processing method, and computer program
WO2018190015A1
