CN114584508A - Method and application based on Rabbit MQ duplex communication - Google Patents

Method and application based on Rabbit MQ duplex communication Download PDF

Info

Publication number
CN114584508A
CN114584508A CN202210205117.8A CN202210205117A CN114584508A CN 114584508 A CN114584508 A CN 114584508A CN 202210205117 A CN202210205117 A CN 202210205117A CN 114584508 A CN114584508 A CN 114584508A
Authority
CN
China
Prior art keywords
queue
message
receiving end
sending end
routing rule
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.)
Granted
Application number
CN202210205117.8A
Other languages
Chinese (zh)
Other versions
CN114584508B (en
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.)
Huayun Data Holding Group Co ltd
Original Assignee
Huayun Data Holding Group 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 Huayun Data Holding Group Co ltd filed Critical Huayun Data Holding Group Co ltd
Priority to CN202210205117.8A priority Critical patent/CN114584508B/en
Publication of CN114584508A publication Critical patent/CN114584508A/en
Application granted granted Critical
Publication of CN114584508B publication Critical patent/CN114584508B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/16Multipoint routing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/302Route determination based on requested QoS
    • H04L45/306Route determination based on the nature of the carried application
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/90Buffering arrangements
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a method based on Rabbit MQ duplex communication and application thereof, wherein the method comprises the following steps: creating a left queue and a right queue, wherein the left queue is used for at least one sending end to monitor the messages sent by at least one receiving end, and the right queue is used for at least one receiving end to monitor the messages sent by at least one sending end; the transmitting end binds the Rabbit MQ switch with the left queue according to the left routing rule and binds the Rabbit MQ switch with the right queue according to the right routing rule; and the sending end communicates with the receiving end after monitoring the handshake message of the receiving end in the left-hand queue, and the handshake message is sent by the receiving end according to the right-hand routing rule. The method can enable the sending end to receive the message by using the left queue and by key: connection.duplex.right sends a message to the switch, and the receiver receives the message using the right-hand queue and by key: connection.duplex.left sends a message to the switch, and duplex communication can be performed only by sending a handshake message by the receiving end.

Description

Method and application based on Rabbit MQ duplex communication
Technical Field
The invention relates to the field of computers, in particular to a Rabbit MQ duplex communication-based method and application.
Background
The application method of message distribution or broadcast by Rabbit MQ in the prior art is operated by a consumer mode. The consumer model is characterized by an unknown number of message publishers to consumers and no concern about whether a consumer is online, as long as a message is produced and pushed to the message bus. In this mode, neither the consumer nor the message publisher is aware of the presence of each other, and thus conventional communication is not possible.
The information disclosed in this background section is only for enhancement of understanding of the general background of the invention and should not be taken as an acknowledgement or any form of suggestion that this information forms the prior art already known to a person skilled in the art.
Disclosure of Invention
The invention aims to provide a method and application based on Rabbit MQ duplex communication, and solves the problems that only point-to-point connection can be carried out when communication with an opposite end is required, and communication cannot be carried out under the condition that the position of the opposite end is unknown.
In order to achieve the above object, an embodiment of the present invention provides a method based on rabbitm MQ duplex communication.
In one or more embodiments of the invention, the method comprises: creating a left queue and a right queue, wherein the left queue is used for at least one sending end to monitor the messages sent by at least one receiving end, and the right queue is used for at least one receiving end to monitor the messages sent by at least one sending end; the transmitting end binds the Rabbit MQ switch with the left queue according to the left routing rule and binds the Rabbit MQ switch with the right queue according to the right routing rule; and the sending end communicates with the receiving end after monitoring a handshake message of the receiving end in the left-direction queue, wherein the handshake message is sent by the receiving end according to the right-direction routing rule.
In one or more embodiments of the present invention, the communicating between the sending end and the receiving end after the sending end monitors the handshake message of the receiving end in the left queue includes: when the queue manager of the sending end monitors that a message arrives in a left queue, the arriving message is written into a reading interface of the sending end; and when monitoring that a message is written in a writing interface of the sending end, the queue manager of the sending end sends the written message to the RabbitMQ switch according to a left-direction routing rule.
In one or more embodiments of the present invention, when the sending end disconnects, the method further includes: and the transmitting end transmits an end message and clears the Rabbit MQ switch, the left queue and the right queue.
In one or more embodiments of the present invention, the communication connection configuration includes: the system comprises a Rabbit MQ address, a user name, a password, a key, a switch, a left-directional queue and a right-directional queue.
In order to achieve the above object, another method for duplex communication based on a rabbitm MQ is provided in the embodiments of the present invention.
In one or more embodiments of the invention, the method comprises: a receiving end respectively creates a left queue and a right queue; the receiving end sends the handshake message to a sending end according to the right-direction routing rule, and communicates with the sending end after the sending end monitors the handshake message in a left-direction queue; the left queue is used for a sending end to monitor messages sent by a receiving end, the right queue is used for a receiving end to monitor messages sent by the sending end, the left queue is bound with a Rabbit MQ switch according to a left routing rule, and the right queue is bound with the Rabbit MQ switch according to a right routing rule.
In one or more embodiments of the invention, the method further comprises: when the queue manager of the receiving end monitors that a message arrives in the right-direction queue, the arriving message is written into a reading interface of the receiving end; and when the queue manager of the receiving end monitors that a message is written in the writing interface of the receiving end, the written message is sent to the Rabbit MQ switch according to the right-direction routing rule.
In another aspect of the invention, a device for duplex communication based on a Rabbit MQ is provided, which comprises a creation module, a routing module and a communication module.
The device comprises a creating module and a sending module, wherein the creating module is used for creating a left queue and a right queue, the left queue is used for at least one sending end to monitor the messages sent by at least one receiving end, and the right queue is used for at least one receiving end to monitor the messages sent by at least one sending end.
And the routing module is used for binding the Rabbit MQ switch with the left queue according to the left routing rule and binding the Rabbit MQ switch with the right queue according to the right routing rule by the sending end.
And the communication module is used for the sending end to communicate with the receiving end after monitoring a handshake message of the receiving end in the left-direction queue, wherein the handshake message is sent by the receiving end according to the right-direction routing rule.
In one or more embodiments of the present invention, the communication module is further configured to: when the queue manager of the sending end monitors that a message arrives in a left queue, the arriving message is written into a reading interface of the sending end; and when monitoring that a message is written in a writing interface of the sending end, the queue manager of the sending end sends the written message to the RabbitMQ switch according to a left-direction routing rule.
In one or more embodiments of the present invention, the communication module is further configured to: and when the sending end is disconnected, the sending end sends an end message and clears the switch, the left queue and the right queue of the Rabbit MQ.
In another aspect of the present invention, there is provided another apparatus for rabbitmq duplex communication, which includes a communication module.
The communication module is used for the receiving end to respectively create a left queue and a right queue; the receiving end sends the handshake message to a sending end according to the right-direction routing rule, and communicates with the sending end after the sending end monitors the handshake message in a left-direction queue; the left queue is used for a sending end to monitor messages sent by a receiving end, the right queue is used for a receiving end to monitor messages sent by the sending end, the left queue is bound with a Rabbit MQ switch according to a left routing rule, and the right queue is bound with the Rabbit MQ switch according to a right routing rule.
In one or more embodiments of the present invention, the communication module is further configured to: when the queue manager of the receiving end monitors that a message arrives in the right-direction queue, the arriving message is written into a reading interface of the receiving end; and when monitoring that a message is written in a writing interface of the receiving end, the queue manager of the receiving end sends the written message to the RabbitMQ switch according to a right-direction routing rule.
In another aspect of the present invention, there is provided an electronic device including: at least one processor; and a memory storing instructions that, when executed by the at least one processor, cause the at least one processor to perform a method of rabbitmq-based duplex communication as described above.
In another aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, which, when being executed by a processor, implements the steps of the method for rabbitmq-based duplex communication as described.
Compared with the prior art, the method and the application based on Rabbit MQ duplex communication can serve as a channel of bidirectional flow by establishing 2 Rabbit MQ message queues and establishing a special routing rule to bind the route with the corresponding message queue, so that a sending end receives messages by using a left queue and receives the messages by a key: connection.duplex.right sends a message to the switch, and the receiver receives the message using the right-hand queue and by key: connection.duplex.left sends a message to the switch, and duplex communication can be performed only by sending a handshake message by the receiving end.
Drawings
Fig. 1 is a flow chart of a transmitting end of a method for duplex communication based on a rabbitmq according to an embodiment of the invention;
fig. 2 is a system structure diagram of a rabbitmq duplex communication-based method according to an embodiment of the invention;
fig. 3 is a flow chart of a routing manager of a rabbitmq duplex communication-based method according to an embodiment of the invention;
fig. 4 is a flowchart of a transmitting-end queue manager of a rabbitmq duplex communication-based method according to an embodiment of the present invention;
fig. 5 is a flow chart of transmitting end data packet transmission of a rabbitmq duplex communication-based method according to an embodiment of the invention;
fig. 6 is a flow chart of a receiving end of a method for rabbitmq duplex communication according to an embodiment of the present invention;
fig. 7 is a flowchart of a receiving end queue manager of a rabbitmq duplex communication-based method according to an embodiment of the present invention;
fig. 8 is a receiving end data packet transmission flow chart of the rabbitmq duplex communication-based method according to an embodiment of the invention;
fig. 9 is a diagram of a transmitting end structure of a device based on rabbitmq duplex communication according to an embodiment of the present invention;
fig. 10 is a receiving end structure diagram of a device based on rabbitmq duplex communication according to an embodiment of the present invention;
fig. 11 is a hardware block diagram of a computing device based on RabbitMQ duplex communication according to an embodiment of the invention.
Detailed Description
The following detailed description of the present invention is provided in conjunction with the accompanying drawings, but it should be understood that the scope of the present invention is not limited to the specific embodiments.
Throughout the specification and claims, unless explicitly stated otherwise, the word "comprise", or variations such as "comprises" or "comprising", will be understood to imply the inclusion of a stated element or component but not the exclusion of any other element or component.
The technical solutions provided by the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
Example 1
Referring to fig. 1 to 5, a method for rabbitit MQ duplex communication according to an embodiment of the present invention is described, which includes the following steps.
In step S101, the transmitting end creates a left-directional queue and a right-directional queue, respectively.
The working principle of the RabbitMQ is that a message publisher sends a message to a RabbitMQ proxy server, a switch in the proxy server receives the message, the message is transmitted to a message queue bound with the switch and stored, and a consumer establishes connection with the message proxy server and then takes out the message from the corresponding message queue for processing.
The communication connection configuration which is appointed to be used by a sending end and a receiving end comprises the following steps: the system comprises a Rabbit MQ address, a user name, a password, a key, a switch to be used during communication, a left queue and a right queue. The switch is used to receive messages sent by message publishers and route the messages to queues in the server. The left and right queues are used to hold messages until sent to the consumer. It is the container of the message and also the end point of the message. A message may be dropped into one or more queues. The message is always in the queue waiting for the consumer to connect to this queue and take it away.
The sending terminal configures a read-write engine of the sending terminal by using a conventional communication connection, wherein the read-write engine comprises a read interface, a write interface, a routing manager and a queue manager. The queue manager of the read-write engine establishes 2 Rabbit MQ message queues serving as channels of bidirectional flow according to communication connection configuration, so that a sending end and a receiving end can use respective corresponding left-direction queues or right-direction queues to monitor messages sent by an opposite side.
In step S102, the sending end binds the rabbitmq switch with the left queue according to the left routing rule and binds the rabbitmq switch with the right queue according to the right routing rule.
And the read-write engine of the sending end is actively connected with the Rabbit MQ according to the configuration information, configures the corresponding message queue name and the router and binds the corresponding queue according to the routing rule.
Specifically, the read-write engine generates a routing rule key according to communication connection configuration: connection.duplex.right and key: complete. left, and create a dedicated communication route. After the queue manager of the read-write engine successfully creates the left queue and the right queue, according to a routing rule key: connection.duplex.right binding right queue, key: connection.duplex.left binds the left queue and informs the queue manager of the ready initialization, thereby realizing duplex communication.
In step S103, the transmitting end communicates with the receiving end after monitoring the handshake message of the receiving end in the left queue.
After receiving a ready signal sent by a routing manager, a queue manager at a sending end starts to monitor messages in a left queue, and a receiving end uses a key: connection.duplex.left actively sends a handshake message, and starts communication after a sending end receives the handshake message sent by a receiving end.
The sending end receives the message by using the left queue and by key: connection.duplex.right sends a message to the switch. The receiving end receives the message by using the right-direction queue and by key: connection.duplicate.left sends a message to the switch.
And when the queue manager at the sending end monitors that the left queue has information, writing the information into a reading interface of the sending end. When the queue manager at the sending end monitors that the writing interface has information to write, according to the corresponding routing rule key: connection.duplex.right sends the information to the exchange of the rabbitmq.
When the sending end or the receiving end needs to be disconnected, an ending message needs to be sent, and after the opposite end receives the disconnection of the ending message, the sending end actively clears the switch, the left queue and the right queue of the RabbitMQ.
Example 2
Referring to fig. 6 to 8, a method for rabbitit MQ duplex communication according to an embodiment of the present invention is described, which includes the following steps.
In step S201, the receiving end creates a left-directional queue and a right-directional queue, respectively.
The invention is not only suitable for the situation of one sending end and one receiving end, but also suitable for the situation of one-to-many, many-to-one and many-to-many, namely, one sending end corresponds to a plurality of receiving ends, or a plurality of receiving ends correspond to one sending end, or a plurality of different receiving ends correspond to a plurality of different sending ends at the same time. In this embodiment, one transmitting end corresponds to multiple receiving ends.
The working principle of the RabbitMQ is that a message publisher sends a message to a RabbitMQ proxy server, an exchanger in the proxy server receives the message, transmits the message to a message queue bound with the exchanger and stores the message, and a consumer establishes connection with the message proxy server and then takes the message out of the corresponding message queue for processing.
The communication connection configuration which is appointed to be used by a sending end and a receiving end comprises the following steps: the system comprises a Rabbit MQ address, a user name, a password, a key, a switch to be used during communication, a left queue and a right queue. The switch is used to receive messages sent by message publishers and route the messages to queues in the server. The left and right queues are used to hold messages until sent to the consumer. It is the container of the message and also the end point of the message. A message may be dropped into one or more queues. The message is always inside the queue waiting for the consumer to connect to the queue and take it away.
The sending end and the receiving end configure and set a read-write engine of the sending end and the receiving end by using a conventional communication connection, and the read-write engine comprises a read interface, a write interface, a route manager and a queue manager. The queue manager of the read-write engine establishes 2 Rabbit MQ message queues serving as channels of bidirectional flow according to communication connection configuration, so that a sending end and a receiving end can use respective corresponding left-direction queues or right-direction queues to monitor messages sent by an opposite side.
In step S202, the receiving end binds the rabbitmq switch to the left queue according to the left routing rule and binds the rabbitmq switch to the right queue according to the right routing rule.
And the read-write engine at the receiving end is actively connected with the Rabbit MQ according to the configuration information, configures the corresponding message queue name and the router and binds the corresponding queue according to the routing rule.
In this embodiment, a sending end, a first receiving end and a second receiving end are used for communication, a left queue is used for the sending end to monitor messages sent by the first receiving end and the second receiving end, a first right queue is used for the first receiving end to monitor the messages sent by the sending end, and a second right queue is used for the second receiving end to monitor the messages sent by the sending end.
The read-write engine generates a routing rule key according to the communication connection configuration: connection.duplex.right.1, key: connection.duplex.right.2 and key: complete. left, and create a dedicated communication route. After the queue manager of the read-write engine successfully creates the left queue and the right queue, according to a routing rule key: connection.duplex.right.1 binds the first right queue, according to the routing rule key: connection.duplex.right.2 bind the second right queue, key: and binding a left queue by connection.duplex.left, and informing a queue manager of ready initialization so as to realize duplex communication.
In step S203, the receiving end actively sends a handshake message according to the routing rule.
After receiving a ready signal sent by a routing manager, a queue manager of a sending end starts to monitor messages in a left queue, and a first receiving end and a second receiving end respectively use keys: connection.duplex.left actively sends a handshake message, and communication is started after a sending end receives the handshake message sent by a first receiving end or a second receiving end.
The sending end receives the message by using the left queue and passes the key: connection.duplex.right.1, key: connection.duplex.right.2 sends a message to the switch. The first receiving end and the second receiving end respectively use the first right queue and the second right queue to receive the messages and pass the key: connection.duplicate.left sends a message to the switch.
And when the queue manager at the sending end monitors that the left queue has information, writing the information into a reading interface of the sending end. When the queue manager at the sending end monitors that the writing interface has information to write, according to the corresponding routing rule key: connection.duplex.right.1 or key: connection.duplex.right.2 sends the information to the exchange of the RabbitMQ.
In step S204, the receiving end listens whether the switch of the RabbitMQ is online.
The communication connection configuration which is appointed to be used by a sending end and a receiving end comprises the following steps: the system comprises a Rabbit MQ address, a user name, a password, a key, a switch to be used during communication, a left queue and a right queue. The switch is used to receive messages sent by message publishers and route the messages to queues in the server. The left and right queues are used to hold messages until sent to the consumer. It is the container of the message and also the end point of the message. A message may be dropped into one or more queues. The message is always in the queue waiting for the consumer to connect to this queue and take it away.
The receiving end sets a read-write engine of the receiving end by using appointed communication connection configuration, and the read-write engine of the receiving end is actively connected with the RabbitMQ according to the configuration information and monitors whether the switchboard of the RabbitMQ is on-line or not. If monitoring the line connection of the Rabbit MQ to the switch, representing that the writing interface of the sending end has information writing, and the information is written into the corresponding routing rule key: connection.duplex.right sends information to the switch of the RabbitMQ, and the switch sends the information to the right-hand queue, at which time the receiver can receive the information by listening to the right-hand queue.
In step S205, when the queue manager of the receiving end detects that information arrives in the right queue, the information is written into the read interface of the receiving end.
The first receiving end and the second receiving end respectively use the first right queue and the second right queue to receive the message of the sending end and pass the key: complete. left sends messages to the switches of rabbitmq, respectively.
When information is written in a write interface of the sending end, the routing rule key corresponding to the information is used for: connection.duplex.right.1 or key: connection.duplex.right.2 sends the information to the switch of the Rabbit MQ, the switch sends the information to the first right queue and the second right queue respectively, at this time, the queue managers of the first receiving end and the second receiving end can both monitor that the corresponding right queue has the information to arrive, and the queue managers of the first receiving end and the second receiving end write the information into the corresponding reading interface.
In step S206, when the queue manager at the receiving end monitors that the information is written in the write interface, the information is sent to the switch of the RabbitMQ according to the corresponding routing rule.
When the information is written in the write-in interface of the first receiving end or the second receiving end, the routing rule key corresponding to the write-in interface is used for: connection.duplex.left sends information to the switch of the Rabbit MQ, the switch sends the information to the left queue, at the moment, the queue manager of the sending end can monitor that the left queue has information to arrive, and the queue manager of the sending end writes the information into the reading interface of the sending end.
As shown in fig. 9, a device based on rabbitit MQ duplex communication according to an embodiment of the present invention is introduced.
In the embodiment of the invention, the device based on Rabbit MQ duplex communication comprises a creation module 901, a routing module 902 and a communication module 903.
The creating module 901 is configured to create a left queue and a right queue, where the left queue is used by at least one sending end to monitor a message sent by at least one receiving end, and the right queue is used by at least one receiving end to monitor a message sent by at least one sending end.
And the routing module 902 is configured to enable the sending end to bind the rabbitmq switch with the left-directional queue according to the left-directional routing rule and bind the rabbitmq switch with the right-directional queue according to the right-directional routing rule.
The communication module 903 is configured to enable the sending end to communicate with the receiving end after the sending end monitors the handshake message of the receiving end in the left-direction queue, where the handshake message is sent by the receiving end according to the right-direction routing rule.
The communication module 903 is further configured to: when monitoring that a message arrives in a left queue, a queue manager of a sending end writes the arrived message into a reading interface of the sending end; and when monitoring that a message is written in a writing interface of the sending end, the queue manager of the sending end sends the written message to the Rabbit MQ switch according to the left-direction routing rule.
The communication module 903 is further configured to: and when the sending end is disconnected, the sending end sends an end message, and clears the switch, the left queue and the right queue of the Rabbit MQ.
As shown in fig. 10, a device based on rabbitit MQ duplex communication according to an embodiment of the present invention is introduced.
In the embodiment of the present invention, the apparatus for duplex communication based on the rabbitmq includes a communication module 1001.
The communication module 1001 is used for the receiving end to respectively create a left queue and a right queue, the receiving end sends the handshake messages to the sending end according to the right routing rule, and the sending end communicates with the sending end after the sending end monitors the handshake messages in the left queue; the left queue is used for the sending end to monitor the message sent by the receiving end, the right queue is used for the receiving end to monitor the message sent by the sending end, the left queue is bound with the Rabbit MQ switch according to the left routing rule, and the right queue is bound with the Rabbit MQ switch according to the right routing rule.
The communication module 1001 is further configured to: when monitoring that a message arrives in a right-direction queue, a queue manager of a receiving end writes the arrived message into a reading interface of the receiving end; and when monitoring that the message is written in the write-in interface of the receiving end, the queue manager of the receiving end sends the written message to the Rabbit MQ switch according to the right-direction routing rule.
Fig. 11 illustrates a hardware block diagram of a computing device 110 for rabbitmq-based duplex communication according to embodiments of the present description. As shown in fig. 11, the computing device 110 may include at least one processor 1101, a storage 1102 (e.g., a non-volatile storage), a memory 1103, and a communication interface 1104, and the at least one processor 1101, the storage 1102, the memory 1103, and the communication interface 1104 are connected together via a bus 1105. The at least one processor 1101 executes at least one computer readable instruction stored or encoded in the memory 1102.
It should be appreciated that the computer-executable instructions stored in the memory 1102, when executed, cause the at least one processor 1101 to perform the various operations and functions described above in connection with fig. 1-11 in the various embodiments of the present specification.
In embodiments of the present description, computing device 110 may include, but is not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile computing devices, smart phones, tablet computers, cellular phones, Personal Digital Assistants (PDAs), handheld devices, messaging devices, wearable computing devices, consumer electronics, and so forth.
According to one embodiment, a program product, such as a machine-readable medium, is provided. A machine-readable medium may have instructions (i.e., elements described above as being implemented in software) that, when executed by a machine, cause the machine to perform various operations and functions described above in connection with fig. 1-11 in the various embodiments of the present specification. Specifically, a system or apparatus may be provided which is provided with a readable storage medium on which software program code implementing the functions of any of the above embodiments is stored, and which causes a computer or processor of the system or apparatus to read out and execute the instructions stored in the readable storage medium.
According to the method and the application based on Rabbit MQ duplex communication in the embodiment of the invention, 2 Rabbit MQ message queues are established to serve as a channel of bidirectional flow, and a special routing rule is established to bind a route with a corresponding message queue, so that a sending end receives messages by using a left queue and receives the messages by a key: connection.duplex.right sends a message to the switch, and the receiver receives the message using the right-hand queue and by key: connection.duplex.left sends a message to the switch, and duplex communication can be performed only by sending a handshake message by the receiving end.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing descriptions of specific exemplary embodiments of the present invention have been presented for purposes of illustration and description. It is not intended to limit the invention to the precise form disclosed, and obviously many modifications and variations are possible in light of the above teaching. The exemplary embodiments were chosen and described in order to explain certain principles of the invention and its practical application to enable one skilled in the art to make and use various exemplary embodiments of the invention and various alternatives and modifications as are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the claims and their equivalents.

Claims (10)

1. A method based on Rabbit MQ duplex communication is characterized by comprising the following steps:
creating a left queue and a right queue, wherein the left queue is used for at least one sending end to monitor the messages sent by at least one receiving end, and the right queue is used for at least one receiving end to monitor the messages sent by at least one sending end;
the transmitting end binds the Rabbit MQ switch with the left queue according to the left routing rule and binds the Rabbit MQ switch with the right queue according to the right routing rule; and
and the sending end communicates with the receiving end after monitoring a handshake message of the receiving end in the left-direction queue, wherein the handshake message is sent by the receiving end according to the right-direction routing rule.
2. The RabbitMQ-based duplex communication method of claim 1, wherein the transmitting end communicates with the receiving end after monitoring the handshake message of the receiving end in the left queue, comprising:
when the queue manager of the sending end monitors that a message arrives in a left queue, the arriving message is written into a reading interface of the sending end; and
and when monitoring that a message is written in a writing interface of the sending end, the queue manager of the sending end sends the written message to the RabbitMQ switch according to a left-direction routing rule.
3. The RabbitMQ-based duplex communication method according to claim 1, wherein when the sender disconnects, the method further comprises:
and the transmitting end transmits an end message and clears the Rabbit MQ switch, the left queue and the right queue.
4. A method based on RabbitMQ duplex communication is characterized by comprising the following steps:
a receiving end respectively creates a left queue and a right queue; and
the receiving end sends a handshake message to a sending end according to a right-direction routing rule, and communicates with the sending end after the sending end monitors the handshake message in a left-direction queue;
the left queue is used for a sending end to monitor messages sent by a receiving end, the right queue is used for a receiving end to monitor messages sent by the sending end, the left queue is bound with a Rabbit MQ switch according to a left routing rule, and the right queue is bound with the Rabbit MQ switch according to a right routing rule.
5. The method for RabbitMQ-based duplex communication according to claim 4, wherein the method further comprises:
when monitoring that a message arrives in a right queue, a queue manager of the receiving end writes the arrived message into a reading interface of the receiving end; and
and when monitoring that a message is written in a writing interface of the receiving end, the queue manager of the receiving end sends the written message to the RabbitMQ switch according to a right-direction routing rule.
6. A device based on RabbitMQ duplex communication, the device comprising:
the system comprises a creating module, a sending module and a receiving module, wherein the creating module is used for creating a left queue and a right queue, the left queue is used for at least one sending end to monitor messages sent by at least one receiving end, and the right queue is used for at least one receiving end to monitor messages sent by at least one sending end;
the routing module is used for binding the Rabbit MQ switch with the left queue according to a left routing rule and binding the Rabbit MQ switch with the right queue according to a right routing rule by the sending end; and
and the communication module is used for the sending end to communicate with the receiving end after monitoring the handshake message of the receiving end in the left-direction queue, wherein the handshake message is sent by the receiving end according to the right-direction routing rule.
7. The apparatus of claim 6, wherein the communication module is further configured to:
when the queue manager of the sending end monitors that a message arrives in a left queue, the arriving message is written into a reading interface of the sending end; and
and when monitoring that a message is written in a writing interface of the sending end, the queue manager of the sending end sends the written message to the RabbitMQ switch according to a left-direction routing rule.
8. A device based on RabbitMQ duplex communication, the device comprising:
the creating module is used for the receiving end to respectively create a left queue and a right queue;
the communication module is used for enabling the receiving end to send the handshake message to the sending end according to the right-direction routing rule and communicating with the sending end after the sending end monitors the handshake message in the left-direction queue; the left queue is used for a sending end to monitor messages sent by a receiving end, the right queue is used for a receiving end to monitor messages sent by the sending end, the left queue is bound with a Rabbit MQ switch according to a left routing rule, and the right queue is bound with the Rabbit MQ switch according to a right routing rule.
9. An electronic device, comprising:
at least one processor; and
a memory storing instructions that, when executed by the at least one processor, cause the at least one processor to perform the method for rabbitm MQ-based duplex communication according to any of claims 1 to 5.
10. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and the computer program, when executed by a processor, implements the steps of the method for rabbitmq-based duplex communication according to any one of claims 1 to 5.
CN202210205117.8A 2022-03-02 2022-03-02 Rabbit MQ duplex communication-based method and application Active CN114584508B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210205117.8A CN114584508B (en) 2022-03-02 2022-03-02 Rabbit MQ duplex communication-based method and application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210205117.8A CN114584508B (en) 2022-03-02 2022-03-02 Rabbit MQ duplex communication-based method and application

Publications (2)

Publication Number Publication Date
CN114584508A true CN114584508A (en) 2022-06-03
CN114584508B CN114584508B (en) 2024-02-06

Family

ID=81777221

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210205117.8A Active CN114584508B (en) 2022-03-02 2022-03-02 Rabbit MQ duplex communication-based method and application

Country Status (1)

Country Link
CN (1) CN114584508B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105471718A (en) * 2015-12-22 2016-04-06 积成电子股份有限公司 Realization method of full duplex message queue
CN110661849A (en) * 2019-08-30 2020-01-07 中国人民财产保险股份有限公司 Request processing method and device, electronic equipment and storage medium
CN112231123A (en) * 2020-10-29 2021-01-15 浙江大华技术股份有限公司 Message processing method, message processing device, storage medium and electronic device
CN113703997A (en) * 2021-08-16 2021-11-26 北京图菱视频科技有限公司 Bidirectional asynchronous communication middleware system integrating multiple message agents and implementation method
CN113971098A (en) * 2021-11-01 2022-01-25 百融至信(北京)征信有限公司 RabbitMQ consumption management method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105471718A (en) * 2015-12-22 2016-04-06 积成电子股份有限公司 Realization method of full duplex message queue
CN110661849A (en) * 2019-08-30 2020-01-07 中国人民财产保险股份有限公司 Request processing method and device, electronic equipment and storage medium
CN112231123A (en) * 2020-10-29 2021-01-15 浙江大华技术股份有限公司 Message processing method, message processing device, storage medium and electronic device
CN113703997A (en) * 2021-08-16 2021-11-26 北京图菱视频科技有限公司 Bidirectional asynchronous communication middleware system integrating multiple message agents and implementation method
CN113971098A (en) * 2021-11-01 2022-01-25 百融至信(北京)征信有限公司 RabbitMQ consumption management method and system

Also Published As

Publication number Publication date
CN114584508B (en) 2024-02-06

Similar Documents

Publication Publication Date Title
CN104935641B (en) A kind of method and apparatus for accelerating file transmission
CN103067257A (en) Method and server and system for achieving data mutual communication in social networking service
CN104348697A (en) Video communication information processing method, device and system
CN104243281A (en) Voice communication method based on mobile Internet
CN105516905A (en) Connection method and device of Bluetooth devices
CN105262673A (en) E-mail reminding method and terminal thereof
CN106126465B (en) A kind of data transmission method and device
CN113301568A (en) Network distribution method and device and intelligent household equipment
CN105550868A (en) Mobile payment method and apparatus
CN112689012A (en) Cross-network proxy communication method and device
CN110247959A (en) A kind of data transmission method and device
CN114584508B (en) Rabbit MQ duplex communication-based method and application
CN112422485B (en) Communication method and device of transmission control protocol
CN104703291A (en) MiFi-based communication method and relevant MiFi
CN104144105A (en) Information transmission method, device and system
CN103430497A (en) Media access contro (MAC) address learning method, controller, and exchange equipment
CN103338248B (en) A kind of method, system and device of two communication account number opening relationships
CN114024870B (en) Network connectivity detection method and system
WO2016095510A1 (en) Path selection method, device and system
CN116243853A (en) Data transmission method and device, electronic equipment and nonvolatile storage medium
CN113438083B (en) Signature adding and checking method and device based on interface automatic test
CN101510901B (en) Communication method, communication apparatus and system between distributed equipment
CN113014610B (en) Remote access method, device and system
CN103220638B (en) Method, system and the terminal of transmission business card
CN104796565A (en) Mobile terminal volume control method, terminal and mobile terminal

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
GR01 Patent grant
GR01 Patent grant