CN110225133B - Message sending method, node, device, system and related equipment - Google Patents

Message sending method, node, device, system and related equipment Download PDF

Info

Publication number
CN110225133B
CN110225133B CN201910538329.6A CN201910538329A CN110225133B CN 110225133 B CN110225133 B CN 110225133B CN 201910538329 A CN201910538329 A CN 201910538329A CN 110225133 B CN110225133 B CN 110225133B
Authority
CN
China
Prior art keywords
message
sent
message sending
node
producer
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.)
Active
Application number
CN201910538329.6A
Other languages
Chinese (zh)
Other versions
CN110225133A (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.)
Hundsun Technologies Inc
Original Assignee
Hundsun Technologies Inc
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 Hundsun Technologies Inc filed Critical Hundsun Technologies Inc
Priority to CN201910538329.6A priority Critical patent/CN110225133B/en
Publication of CN110225133A publication Critical patent/CN110225133A/en
Application granted granted Critical
Publication of CN110225133B publication Critical patent/CN110225133B/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
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/55Push-based network services

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a message sending method, a node, a device, a system and related equipment, wherein the method is applied to a message sending system comprising at least two message sending nodes and comprises the following steps: any message sending node in the message sending system receives a message to be sent by a producer; any one message sending node synchronizes the message to be sent to other message sending nodes in the message sending system, so that any one or more message sending nodes in the message sending system send the message to be sent to the consumer. In the invention, even if one or more message sending nodes in the message sending system are in failure, the normal operation of the message sending system is not influenced, the influence of the active-standby switching operation of the nodes on message sending is avoided, and the risk of message sending service interruption is reduced.

Description

Message sending method, node, device, system and related equipment
Technical Field
The present application relates to the field of communications technologies, and in particular, to a message sending method, a node, an apparatus, a system, and a related device.
Background
At present, a message sending system is generally provided with a standby node for message backup, and the message backup in the standby node is utilized to ensure the reliability of message sending. The specific treatment process comprises the following steps:
a message producer (hereinafter, referred to as producer) establishes communication connection with a master node in a message transmission system, and after generating messages, sequentially transmits the messages to the master node in the message transmission system. And the main node puts the messages into the corresponding queues and numbers the messages uniformly according to the receiving sequence, and then synchronizes the messages in the queues to the standby nodes. After receiving the ordered messages in the queue, the standby node replies confirmation information to the main node, and the main node replies confirmation information to the producer to the received messages. Finally, the message is sent by the primary or backup node to the message consumer.
In the message sending system, because the identities and processing logics of the main node and the standby node are different, and only one main node exists in the message sending system at the same time to ensure the normal work of the system, the main-standby switching of the nodes is required when the main node fails. However, if the standby node is switched too early, two main nodes exist in the message sending system, which causes split brain; if the standby node is not switched in time or during the switching period of the main and standby nodes, the message sending system can not work normally.
Disclosure of Invention
In view of this, embodiments of the present application provide a message sending method, a node, an apparatus, a system, and related devices, which can solve the problem in the prior art that a message sending system cannot work normally due to active/standby switching of nodes.
A first aspect of an embodiment of the present application provides a message sending method, which is applied to a message sending system, where the message sending system includes at least two message sending nodes; the method comprises the following steps:
any message sending node in the message sending system receives a message to be sent by a producer;
and the any message sending node synchronizes the message to be sent to other message sending nodes in the message sending system, so that the any one or more message sending nodes in the message sending system can send the message to be sent to the consumer.
Optionally, the message to be sent carries a producer identifier and a message number; after the message sending node receives the message to be sent, the method further includes:
the message sending node puts the message to be sent into a recombination queue corresponding to a producer identifier carried by the message to be sent;
and the message sending node sorts the messages in the recombination queue according to the message numbers.
Optionally, the message sending node sorts the messages in the reassembly queue according to the message numbers, and then further includes:
the message sending node judges whether the message number carried by the message to be sent is an expected message number;
when the message number carried by the message to be sent is the expected message number, the message sending node sends all messages with continuous message numbers starting from the expected message number in the recombination queue to a consumer, and updates the expected message number;
the initial expected message number is the minimum message number, and the updated expected message number is the next message number of the maximum message number carried by all the sent messages.
Optionally, the message sending node sends all messages with consecutive message numbers starting from the expected message number in the reassembly queue to the consumer, and then further includes:
and the message sending node removes the sent messages in the reassembly queue.
Optionally, the message sending node sends all messages with consecutive message numbers starting from the expected message number in the reassembly queue to the consumer, and then further includes:
the message sending node searches for the message which is sent by the producer and comes from each message;
determining the message with the largest message number from the messages which are found to be from the producer;
and according to the message number carried by the message with the largest determined message number, replying the message to the producer.
A second aspect of the embodiments of the present application provides a message sending method, which is applied to a message sending system, where the message sending system includes at least two message sending nodes; the method comprises the following steps:
the producer establishes communication connection with each message sending node in the message sending system in advance;
the producer sends the produced message to be sent to any message sending node in the message sending system, so that after the message sending node receiving the message to be sent synchronizes the message to be sent to other message sending nodes in the message sending system, any one or more message sending nodes in the message sending system send the message to be sent to the consumer.
Optionally, the message to be sent carries a producer identifier and a message number, so that the message sending node places the message to be sent in a reassembly queue corresponding to the producer identifier carried in the message to be sent, and sorts the messages in the reassembly queue according to the message number.
Optionally, the method further includes:
and if the producer does not receive the message confirmation which is sent by the message sending node and corresponds to the message to be sent within the preset overtime, the producer sends the message to be sent to any message sending node in the message sending system again.
Optionally, the preset timeout time is increased according to an increase of the number of times of sending the message to be sent.
Optionally, the method further includes:
and when the preset timeout time is larger than a preset threshold value, resetting the preset timeout time by the producer.
Optionally, the sending, by the producer, the produced message to be sent to any node in the message sending system includes:
the producer obtains the service quality of the communication connection established with each message sending node in the message sending system;
and the producer sends the information to be sent through the communication connection with the service quality exceeding a preset threshold value.
Optionally, the obtaining, by the producer, the service quality of the communication connection established with each message sending node in the message sending system specifically includes:
the producer sends a heartbeat request message to the message sending node, so that the message sending node replies a heartbeat response message to the producer after receiving the heartbeat request message;
and the producer acquires the service quality of the communication connection between the producer and the message sending node according to the received heartbeat response message.
A third aspect of the embodiments of the present application provides a message sending node, where the message sending node is deployed in a message sending system, and the message sending system further includes at least one peer-to-peer message sending node that is peer-to-peer with the message sending node; the message sending node comprises: the device comprises a receiving module, a synchronization module and a sending module;
the receiving module is used for receiving a first message to be sent by a producer; the peer-to-peer message sending node is also used for receiving a second message to be sent by any one of the peer-to-peer message sending nodes; the second message to be sent is sent to the peer-to-peer message sending node by the producer;
the synchronization module is configured to send the first message to be sent to each peer message sending node;
the sending module is used for sending the first message to be sent and/or the second message to be sent to a consumer.
Optionally, the first message to be sent and the second message to be sent carry a producer identifier and a message number; the message sending node further comprises: a reorganization module and a sequencing module;
the reassembly module is configured to place the first message to be sent into an reassembly queue corresponding to a producer identifier carried by the first message to be sent, and place the second message to be sent into an reassembly queue corresponding to a producer identifier carried by the second message to be sent;
and the sequencing module is used for sequencing the messages in the recombination queue according to the message numbers.
Optionally, the message sending node further includes: a judging module and a response module;
the judging module is used for judging whether the message number carried by the message to be sent is an expected message number;
the sending module is specifically configured to send all messages with consecutive message numbers starting from the expected message number in the reassembly queue to a consumer when the judging module judges that the message number carried by the message to be sent is the expected message number, and update the expected message number;
the initial expected message number is the minimum message number, and the updated expected message number is the next message number of the maximum message number carried by all the sent messages.
Optionally, the method further includes: a removal module;
and the removing module is used for removing the sent messages in the reorganization queue.
Optionally, the method further includes: the device comprises a searching module, a determining module and a responding module;
the searching module is used for searching the message which is sent and has the source of the producer;
the determining module is used for searching the messages with the source of the producer from the searching module and determining the message with the largest message number;
and the response module is used for replying the message to the producer according to the message number carried by the message with the largest message number determined by the determination module.
A fourth aspect of the embodiments of the present application provides a message sending apparatus, which is applied to a message sending system, where the message sending system includes at least two message sending nodes; the device comprises: the system comprises a connection establishing module, a message production module and a message sending module;
the connection establishing module is used for establishing communication connection with each message sending node in the message sending system;
the message production module is used for producing messages to be sent;
the message sending module is configured to send the message to be sent to any one of the message sending nodes in the message sending system, so that after the message sending node that receives the message to be sent synchronizes the message to be sent to other message sending nodes in the message sending system, any one or more of the message sending nodes in the message sending system sends the message to be sent to a consumer.
Optionally, the message to be sent carries a producer identifier and a message number, so that the message sending node places the message to be sent in a reassembly queue corresponding to the producer identifier carried in the message to be sent, and sorts the messages in the reassembly queue according to the message number.
Optionally, the method further includes: a response waiting module;
the response waiting module is configured to trigger the message sending module to send the message to be sent to any message sending node in the message sending system again when a message acknowledgement corresponding to the message to be sent and sent by the message sending node is not received within a preset timeout period.
Optionally, the preset timeout time is increased according to an increase of the number of times of sending the message to be sent.
Optionally, the method further includes: a time reset module;
the time resetting module is used for resetting the preset overtime time when the preset overtime time is larger than a preset threshold value.
Optionally, the message sending module specifically includes: the method comprises the steps of obtaining a submodule, a judging submodule and a sending submodule;
the obtaining submodule is used for obtaining the service quality of the communication connection established with each message sending node in the message sending system;
the judging submodule is used for judging the communication connection with the highest service quality according to the acquired service quality;
and the sending submodule is used for sending the information to be sent through the communication connection with the highest service quality judged by the judging submodule.
Optionally, the obtaining sub-module specifically includes: a first sub-module, a second sub-module, and a third sub-module;
the first sub-module is configured to send a heartbeat request message to the message sending node, so that the message sending node replies a heartbeat response message to the producer after receiving the heartbeat request message;
the second sub-module is configured to receive a heartbeat response message replied by the message sending node;
and the third sub-module is used for acquiring the service quality of the communication connection between the message sending node and the second sub-module according to the heartbeat response message received by the second sub-module.
A fifth aspect of the embodiments of the present application provides a message sending system, including any one of at least two message sending nodes as provided in the third aspect.
Optionally, any one of the message sending apparatuses provided in the fourth aspect above is further included.
A sixth aspect of embodiments of the present application provides a computer-readable storage medium for storing program code for executing any one of the message sending methods provided in the first and second aspects.
A seventh aspect of the present embodiment provides a message sending apparatus, including a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to execute any one of the message sending methods provided in the first aspect and the second aspect according to instructions in the program code.
Compared with the prior art, the method has the advantages that:
in the embodiment of the application, a plurality of message sending nodes included in the message sending system can receive a message to be sent by a producer, and synchronize to other message sending nodes in the message sending system after receiving the message to be sent by the producer so as to ensure the reliability of message sending. The identities of all message sending nodes in the message sending system are equal, a producer can send a message to be sent to any message sending node in the message sending system, a consumer can also obtain the message to be sent from any message sending node in the message sending system, even if one or more message sending nodes in the message sending system are in failure, the normal operation of the message sending system is not influenced, the influence of the active-standby switching operation of the nodes on message sending is avoided, and the risk of message sending service interruption is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be 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 described in the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic diagram of a message sending system of a main/standby cluster structure in the prior art;
fig. 2 is a schematic view of an application scenario of a message sending method according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a message sending method according to an embodiment of the present application;
fig. 4 is a schematic flowchart of another message sending method according to a first embodiment of the present application;
fig. 5 is a schematic view of another application scenario of a message sending method according to an embodiment of the present application;
fig. 6 is a schematic flowchart of another message sending method according to a first embodiment of the present application;
fig. 7 is a flowchart illustrating another message sending method according to an embodiment of the present application;
fig. 8 is a flowchart illustrating a message sending method according to a second embodiment of the present application;
fig. 9 is a schematic structural diagram of a message sending node according to a third embodiment of the present application;
fig. 10 is a schematic structural diagram of another message sending apparatus according to the fourth embodiment of the present application.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
For ease of understanding, a plurality of technical terms referred to in the embodiments of the present application will be first described below.
Clustering: a plurality of logic nodes form a whole to provide services to the outside jointly.
Main and standby clusters: a cluster is formed by a main node and a plurality of standby nodes, the standby nodes depend on the main node, normal work is kept by synchronizing the state of the main node, the main node fails, and the cluster interrupts service.
Peer-to-peer clustering: a cluster is formed by a plurality of nodes with equal roles, the nodes have no primary and secondary points, any node fails, and the cluster can keep normal work.
Message producer (hereinafter simply producer): producing the message and sending the message to the message sending system.
Message consumers (hereinafter simply consumers): a message is received from a messaging system and processed.
The message sending system comprises: and receiving messages sent by each producer, and sending the messages to each consumer in sequence.
Message recombination: the method is characterized in that a sender sends a plurality of messages simultaneously, due to intermediate equipment or system reasons, the messages can be out of order when arriving at a receiver, the receiver needs to buffer the out-of-order messages firstly, the process is called message recombination, and a device for buffering the out-of-order messages is called a recombination queue.
The existing message sending system generally utilizes a main/standby cluster structure to ensure the reliability of the system. Referring to fig. 1, a conventional message sending system with a master/slave cluster structure is shown.
The active/standby cluster is composed of a main node and a plurality of standby nodes (fig. 1 only shows one standby node as an example), and the standby nodes depend on the main node and keep normal operation by synchronizing the states of the main node. The specific flow of message sending is as follows:
the producer 1 and the producer 2 both establish communication connection with the master node, the master node sets a recombination queue for each communication connection, and different producers are distinguished by using different communication connections to ensure the reliable and ordered sending of messages. In the process of sending the messages, the producer 1 and the producer 2 respectively send the messages 1, 2 and 3 to the main node sequentially through corresponding communication connections, the main node puts the received messages into a global queue and then numbers the messages uniformly (for example, the number is 1-6) so as to ensure that the sequence of the messages is reliable when the messages are synchronized to the standby nodes, and then the messages in the global queue are synchronized to each standby node. After receiving the synchronous message, the standby node replies confirmation information to the main node, and the main node replies confirmation information to the producer 1 and the producer 2 respectively. Finally the primary and backup nodes are sending messages to the connected consumers.
It can be seen from the above flow that one and only one master node must exist in the message sending system at the same time, and once the master node fails, the message sending system will interrupt service. Therefore, when the master node fails, in order to recover the normal operation of the message sending system, the standby node in the system needs to be switched to the master node, so as to perform the active-standby switching of the nodes.
However, the existing active/standby switching mechanism may have the following problems: when the main node normally operates, if the standby node is switched to the main node by mistake, a plurality of main nodes exist in the system and the system cannot work normally; when the main node fails, if other standby nodes are not switched to the main node in time, the system cannot work normally because the main node does not exist; during the active-standby switching period, no main node in the system causes service interruption.
In order to solve the problem that the master-slave switching of nodes in a master-slave cluster can cause the system to be incapable of working normally, the embodiment of the application provides a message sending method, a node, a system and a device, wherein the message sending system is constructed by utilizing a peer-to-peer cluster structure, so that the identities of a plurality of message sending nodes in the message sending system are equal, a producer can send a produced message to be sent to any message sending node in the system, a consumer can also obtain the message to be sent from any message sending node in the message sending system, when part of the message sending nodes are in failure, the message sending system can still work normally, the master-slave switching operation is avoided, and the risk of message sending service interruption is reduced.
Based on the above-mentioned ideas, in order to make the above-mentioned objects, features and advantages of the present application more comprehensible, specific embodiments of the present application are described in detail below with reference to the accompanying drawings.
A message sending method provided in an embodiment of the present application is applied to a message sending system, and refer to fig. 2, which is a schematic structural diagram of the message sending system provided in the embodiment of the present application. In the embodiment of the application, the message sending system comprises a plurality of message sending nodes, one or more producers can establish communication connection with each message sending node in the message sending system, and the plurality of message sending nodes in the message sending system can send messages stored on the message sending nodes to connected consumers. In one particular example, the producer may be a sender (publisher) of a subscription message in a subscription and publication system, the consumer may be a recipient (subscriber) in a subscription and publication system, and the messaging system may be a message broker (broker) in a subscription and publication system. Fig. 2 only illustrates any two message sending nodes, i.e., the first node 101 and the second node 102, in the message sending system, and any two producers, i.e., the producer a and the producer b, in the multiple producers, which are taken as examples, and the number of message sending nodes and the number of connected producers in the message sending system are not limited in the embodiment of the present application.
For convenience of description, the following describes in detail a message sending method applied to a message sending system according to an embodiment of the present application with reference to the message sending system shown in fig. 2.
The first embodiment is as follows:
referring to fig. 3, this figure is a schematic flowchart of a message sending method according to an embodiment of the present application.
The message sending method provided in the first embodiment of the present application may specifically include the following steps S301 to S302.
S301: any message sending node in the message sending system receives a message to be sent by a producer.
In the embodiment of the application, because any message sending node in the message sending system can directly receive the message to be sent from the producer, the normal work of a message receiving mechanism of the message sending system cannot be influenced by the fault of a part of message sending nodes in the system. Taking the message sending system shown in fig. 2 as an example, the node that receives the message to be sent by the producer may be the first node 101 or the second node 102, and for convenience of description, the message sending method provided in the embodiment of the present application is described below by taking the first node 101 as an example of receiving the message to be sent by the producer.
It is understood that the producer of the message to be sent may be any producer (such as producer a or producer b shown in fig. 2) connected in the message sending system, and in a specific example, the message to be sent may be a subscription message produced by a publisher of the message in a subscription sending system.
In practical applications, a producer may select a communication connection for sending a message to be sent according to quality of service (QoS) of each communication connection, so as to achieve a load balancing effect. The specific method for realizing load balancing is not limited in the present application, for example, a producer may select the communication connection with the fastest response speed to send a message to be sent according to the response speed of the communication connection between the producer and each message sending node.
S302: the message sending node synchronizes the message to be sent received from the producer to other message sending nodes in the message sending system, so that any one or more message sending nodes in the message sending system can send the message to be sent to the consumer.
It can be understood that the first node 101 may synchronize the message to be sent to all the rest message sending nodes in the message sending system, and may also synchronize the message to be sent to the rest message sending nodes in the message sending system. And any one or more of the message sending nodes which receive the message to be sent in the message sending system sends the message to be sent to the consumer.
In practical applications, in order to ensure reliability and convenience of message transmission, all message sending nodes in a message sending system may receive the message to be sent, and the message to be sent received by each message sending node may be sent by a producer, or any other message sending node in the message sending system may be synchronized, which is not limited herein. Therefore, after any consumer establishes communication connection with any message sending node in the message sending system, the message to be sent can be directly obtained from the connected message sending node, and the message is sent. It should be noted that, in the embodiment of the present application, the number of consumers and the message sending nodes connected to the consumers in detail are not limited, and are not described herein again.
In the embodiment of the application, a plurality of message sending nodes included in the message sending system can receive a message to be sent by a producer, and synchronize to other message sending nodes in the message sending system after receiving the message to be sent by the producer so as to ensure the reliability of message sending. The identities of all message sending nodes in the message sending system are equal, a producer can send a message to be sent to any message sending node in the message sending system, a consumer can also obtain the message to be sent from any message sending node in the message sending system, even if one or more message sending nodes in the message sending system are in failure, the normal operation of the message sending system is not influenced, the influence of the active-standby switching operation of the nodes on message sending is avoided, and the risk of message sending service interruption is reduced.
The above description explains how any message sending node in the message sending system sends a message, and in the embodiment of the present application, there are multiple sources of messages to be sent received by the message sending node (i.e., a producer and other message sending nodes in the message sending system), and the message sending node cannot learn the exact order of the received messages to be sent, which may cause unreliable message sending. Taking the message sending system shown in fig. 2 as an example, when the producer a directly sends a first message to the first node 101, then sends a second message to the second node 102, and then sends a third message to the first node 101. Because the second message is synchronized from the second node to the first node 101, and is affected by various factors such as network delay, the first node 101 cannot clearly receive the sequence among the first message, the second message and the third message, which results in unreliable message transmission. Moreover, since there may be a plurality of producers (such as producer a and producer b) sending messages to be sent to the message sending nodes in the message sending system at the same time, the first node 101 cannot determine the source of the messages to be sent synchronized by other message sending nodes, which also causes disorder and unreliability of message sending.
In order to ensure the sequentiality and the integrity of message transmission, in some possible implementation manners of the embodiment of the present application, a message to be transmitted not only carries a message number, but also carries a producer identifier of a producer of the message to be transmitted, so that a message transmitting node does not confuse messages produced by various producers when the message is recombined and transmitted, and the accuracy of message transmission and the reliability of a message transmitting system are ensured. As an example, the producer identification may be a system number of the producer, an Identification (ID) of the producer, an IP address, and the like, which is not limited in this application.
Based on this, after the message sending node receives the message to be sent, in order to ensure the accuracy and reliability of the message sending, the message sending node can also perform message recombination on the received message to be sent. Specifically, referring to fig. 4, after step S301, steps S401 to S402 may be further included:
s401: and the message sending node puts the message to be sent into a recombination queue corresponding to the producer identifier carried by the message to be sent.
S402: and the message sending node sorts the messages in the recombination queue according to the message numbers.
In the embodiment of the present application, any message sending node (such as the first node 101 and the second node 102 shown in fig. 2) in the message sending system establishes a reassembly queue (which may be referred to as named reassembly queue) corresponding to each connected producer. Any message sending node in the message sending system can put the message to be sent, which is directly received or obtained through message synchronization, into a recombination queue corresponding to the producer identifier carried by the message sending node according to the producer identifier carried by the message to be sent, and carry out message recombination on the message in the recombination queue according to the message number carried by the message to be sent under the condition that the message to be sent produced by each producer is not confused.
Continuing with the example of the system shown in fig. 2, referring to fig. 5, the first node and the second node both establish a named reassembly queue corresponding to their producer identifiers for producer a and producer b, respectively, for performing message reassembly on messages to be sent a1, a2, and a3 sent by producer a and messages to be sent b1, b2, and b3 sent by producer b, so as to avoid confusion of messages produced by different producers. Wherein a and b are the producer's identification, and 1-3 are the message numbers.
In view of producer identification and message sequence number carried by a message to be sent, and message synchronization between a named recombination queue correspondingly set for each producer identification by each message sending node in a message sending system and each message sending node, no matter which message sending node in the message sending system the message to be sent is sent by the producer, each message sending node in the message sending system can always receive all messages to be sent by the producer, and the sequence of the messages to be sent can be ensured to be consistent with the sequence of production and sending of the producer, so that the consistency and reliability of message sending are ensured.
It should be noted that, in the embodiment of the present application, the execution sequence of steps S302 and steps S401 to S402 is not limited, and the first node may perform message reassembly on the received message to be sent first and then synchronize the message to be sent to the second node, or synchronize the message to be sent to the second node and then perform message reassembly, or perform synchronization of the message and message reassembly in parallel.
In the embodiment of the application, the message to be sent, which is produced by the producer, may carry a message number and a producer identifier, and each message sending node in the message sending system sets a reassembly queue corresponding to the producer identifier for the producer establishing a communication connection with the message sending node. When receiving a message to be sent, the message sending node can put the message to be sent into a corresponding reassembly queue according to a producer identifier carried by the message to be sent, and reassemble the message according to a message number carried by the message to be sent under the condition that the message to be sent produced by each producer is not confused, so as to ensure the order of the message. When part of message sending nodes of the message sending system are in fault, message recombination and sequential sending can be still realized, and the reliability of message sending is further ensured.
The above description explains how a message sending node in a message sending system receives a message to be sent and in some examples, how the message is reassembled, and the following description continues to describe how the message sending node sends the message to be sent to a consumer. Because the message sending node has already carried on the message reorganization according to producer's label and message number that the message to be sent carries, in order to guarantee order nature and integrality that the message sends, the message sending node will also send the message order in the reorganization queue to the consumer according to producer's label and message number that the message to be sent carries.
Specifically, in some possible implementation manners of the embodiment of the present application, referring to fig. 6, after step S402, the method may further include:
s601: the message sending node judges whether the message number carried by the message to be sent is an expected message number; if yes, go to step S602.
S602: the message sending node sends all the messages with continuous message numbers starting from the expected message number in the recombination queue to the consumer, and updates the expected message number.
In this embodiment of the present application, the initial expected message number is the minimum message number (for example, 1), and the updated expected message number is the next message number of the maximum message number carried by all the sent messages. Therefore, the message sending node can be ensured to send the ordered messages in the recombination queue to the consumer, and the reliability of message sending is ensured. For ease of understanding, steps S601-S602 are described below with reference to a specific example.
Taking the example shown in fig. 5, the initial expected message number is 1. In a possible case, the reassembly queue corresponding to a in the first node is empty, at this time, the first node receives the message a1 to be sent, the first node sends the message a1 to be sent to the consumer, and updates the expected message number to 2; in another possible case, a message a2 to be sent exists in the reassembly queue corresponding to a in the first node, because the expected message number is 1, the first node does not send a message a2 to be sent, at this time, the first node receives a1 to be sent, the first node sends messages a1 and a2 to be sent to the consumer, and the expected message number is updated to 3; in yet another possible case, there are messages a2 and a3 to be sent in the reassembly queue corresponding to a in the first node, because the expected message number is 1, the first node does not send messages a2 and a3 to be sent, at this time, the first node receives message a1 to be sent, the first node sends messages a1, a2 and a3 to be sent to the consumer, the first node can send messages a1, a2 and a3 to the consumer one by one in sequence, or can send messages a1, a2 and a3 in a packet in batch to the consumer, and then update the expected message number to 4; by analogy, the description is omitted.
It should be noted that any message sending node in the message sending system can send the to-be-sent messages produced by each producer to the consumers one by one according to the message numbers carried by the to-be-sent messages. Continuing with fig. 5 as an example, the messages a1, a2 and a3 to be sent produced by the producer a can be sent to the consumer in sequence, and then the messages b1, b2 and b3 to be sent produced by the producer b can be sent to the consumer in sequence; the messages to be sent b1, b2 and b3 produced by the producer b may be sent to the consumer sequentially, and then the messages to be sent a1, a2 and a3 produced by the producer a may be sent to the consumer sequentially, which is not limited in the embodiment of the present application.
In some possible implementation manners of the embodiment of the present application, in order to reduce the data amount, after step S602, the method may further include:
s603: the message sending node removes the sent message in the reassembly queue.
Continuing with the previous example, when there is a message a2 to be sent in the reassembly queue corresponding to a in the first node, because the expected message number is 1, the first node does not send or move out the message a2 to be sent, and at this time, the first node receives the message a1 to be sent, and the first node sends the messages a1 and a2 to be sent to the consumer and moves the messages a1 and a2 to be sent out of the reassembly queue corresponding to a.
The above describes how a message sending node sends a message to be sent to a consumer. In specific implementation, in order to ensure the integrity of message transmission, the message transmitting node may transmit a message acknowledgement to the corresponding producer after transmitting the message to be transmitted to the consumer, so that the producer can know the transmission state of the message to be transmitted, and avoid missed transmission and multiple transmission of the message.
As an example, the message to be sent may, for each message sent to the consumer, send the corresponding message determination to the producer. However, the inventor of the present application finds in research that the above-mentioned manner can ensure the integrity of message transmission, but may result in more network communications, occupy network resources, and affect the efficiency of message transmission. For this reason, in one example, only the message sending node in the message sending system that directly receives the message to be sent from the producer may send the corresponding message acknowledgement to the producer, so as to avoid the repeated sending of the message acknowledgement.
In another example, the data determined by the transmitted message may be further reduced on the basis of ensuring the integrity of the message transmission, so as to reduce network communication and save network resources, which is described in detail below:
in some possible implementation manners of the embodiment of the present application, referring to fig. 7, after the message sending node sends all messages in the reassembly queue that have consecutive message numbers from the expected message number to the consumer, the method may further include:
s701: the message sending node searches the message which is sent by the producer and is sourced from each message.
It can be understood that the message source received by the message sending node includes a producer and other message sending nodes in the message sending system, and any message source determining method may be adopted to obtain the message source of the message sent by the message sending node, which is not described herein again.
S702: and determining the message with the largest message number from the searched messages with the source as the producer.
S703: and according to the message number carried by the message with the maximum message number, determining the reply message to the producer.
In the embodiment of the application, the message sending node can determine the message corresponding to the message with the largest message number in the messages sent by the message sending node and originating from the producer to the producer, and the producer can determine that the message with the number smaller than the largest message number is sent to the consumer completely without resending, so that the number of the sent message is reduced, the network communication is reduced, and the network resources are saved.
Continuing with the example shown in FIG. 5, assuming that messages a1 and a3 are sent by producer a to the first node and message a2 is sent by producer a to the second node, when the first node sends message a1-a3 to the consumer, the first node determines to producer a according to the message a3 reply message, and when the second node sends message a1-a3 to the consumer, the first node determines to producer a according to the message a2 reply message, and the sending of the message determination corresponding to message a1 is reduced. It should be noted that, each message sending node in the message sending system determines to send the message with the maximum message number from which the producer is the source in the sent message to the producer, so that missed sending of the message determination can be avoided, and the efficiency and effect of message sending are ensured.
Example two:
based on the message sending method applied to the message sending system provided in the first embodiment, a second embodiment of the present application further provides a message sending method applied to a producer, which is used for sending a message to a consumer through the message sending system shown in fig. 2. For the description of the message sending system, reference may be made to the above related contents, which are not described herein again.
Referring to fig. 8, this figure is a schematic flowchart of a message sending method according to a second embodiment of the present application.
The message sending method applied to the producer provided by the embodiment of the application comprises the following steps:
s801: the producer establishes communication connection with each message sending node in the message sending system in advance.
In the embodiment of the present application, the producer may be any one of producers (such as producer a or producer b shown in fig. 2) connected to the message sending system, and may generate a message to be sent. In one particular example, the producer may be a publisher (publisher) that subscribes to messages in the sending system. The producer and each message sending node in the message sending system establish communication connection, namely the produced message can be sent to any message sending node in the message sending system, when part of the message sending nodes in the message sending system are in fault, the producer can also send the message to be sent to other message sending nodes which normally work, so that the consumer can receive the message to be sent and send the message, and the message sending is realized.
S802: the producer sends the produced message to be sent to any message sending node in the message sending system, so that after the message sending node receiving the message to be sent synchronizes the message to be sent to other message sending nodes in the message sending system, any one or more message sending nodes in the message sending system send the message to be sent to the consumer.
In the embodiment of the application, in order to ensure the reliability of message sending, after receiving a message to be sent by a producer, a message sending node synchronizes the message to be sent to other message sending nodes of a message sending system. For the description of the message sending node, reference may be made to the related content of the first method embodiment described above, and details are not described here.
In some possible implementations, in order to ensure the communication quality, step S802 may specifically include:
a producer acquires the service quality of communication connection established with each message sending node in a message sending system; and sending the information to be sent through the communication connection with the service quality exceeding the preset threshold value.
In one example, the producer may determine its quality of service based on, among other factors, the response speed of each communication connection. In another example, the producer may send a heartbeat request message to the message sending node, so that the message sending node replies a heartbeat response message to the producer after receiving the heartbeat request message. And the producer acquires the service quality of the communication connection between the producer and the message sending node according to the received heartbeat response message. The specific determination method of the service quality in the embodiment of the present application is not limited. The producer sends the message to be sent through the communication connection with the highest service quality, so that the message sending efficiency can be improved, and the load balancing effect can be achieved.
In the embodiment of the application, a producer establishes communication connection with each message sending node in a message sending system, a message to be sent can be sent to any message sending node in the message sending system, and after the message sending node receives the message to be sent by the producer, the message to be sent is synchronized to other message sending nodes in the message sending system, so that the reliability of message sending is ensured. The identities of all message sending nodes in the message sending system are equal, a producer can send a message to be sent to any message sending node in the message sending system, a consumer can also obtain the message to be sent from any message sending node in the message sending system, even if one or more message sending nodes in the message sending system are in failure, the normal operation of the message sending system is not influenced, the influence of the active-standby switching operation of the nodes on message sending is avoided, and the risk of message sending service interruption is reduced.
In some possible implementation manners of the embodiment of the present application, in order to ensure the order and integrity of message transmission, a to-be-transmitted message sent by a producer may carry a producer identifier and a message number, so that a message sending node places the to-be-transmitted message into a reassembly queue corresponding to the producer identifier carried by the to-be-transmitted message, and sorts messages in the reassembly queue according to the message number (i.e., performs message reassembly). For the description of the producer identifier, the message number and the message reassembly, reference may be made to the related contents in the first embodiment, which is not described herein again.
In view of producer identification and message sequence number carried by a message to be sent, and message synchronization between a named recombination queue correspondingly set for each producer identification by each message sending node in a message sending system and each message sending node, no matter which message sending node in the message sending system the message to be sent is sent by the producer, each message sending node in the message sending system can always receive all messages to be sent by the producer, and the sequence of the messages to be sent can be ensured to be consistent with the sequence of production and sending of the producer, so that the consistency and reliability of message sending are ensured.
Because the message sending node carries out message recombination according to the producer identification and the message number carried by the message to be sent, the message sending node also sends the message sequence in the recombination queue to the consumer according to the producer identification and the message number carried by the message to be sent. In specific implementation, in order to ensure the integrity of message transmission, the message transmitting node may transmit a message acknowledgement to the corresponding producer after transmitting the message to be transmitted to the consumer, so that the producer can know the transmission state of the message to be transmitted, and avoid missed transmission and multiple transmission of the message. When the missed sending of the message to be sent occurs, the producer does not receive the corresponding message determination, and the message to be sent can be retransmitted to any message sending node in the message sending system.
In a possible embodiment, after step S802, the method further includes:
and if the producer does not receive the message confirmation which is sent by the message sending node and corresponds to the message to be sent within the preset overtime, the producer sends the message to be sent to any message sending node in the message sending system again.
In practical applications, the preset timeout time may be set according to specific needs, and is not limited herein. As an example, the preset timeout time may be increased according to an increase in the number of times the message to be sent is sent. In an example, after the producer sends the message to be sent to any message sending node in the message sending system, if the message acknowledgement of the message to be sent is not received within the first time interval (i.e., the preset timeout), the message to be sent is sent to any message sending node in the message sending system again. Then, if the message acknowledgement of the message to be sent is not received in the second time interval (i.e. the increased preset timeout), the message to be sent is sent to any message sending node in the message sending system again. The second time interval is greater than the first time interval. The timeout time (namely the preset timeout time) for waiting for the message confirmation after each transmission is increased along with the increase of the timeout times, so that the network congestion caused by excessive retransmission times is avoided. The specific duration of the preset timeout period waiting after each transmission is not limited, and is not listed here.
It should be noted that, in some possible designs, the timeout time may be reset to the initial preset timeout time when the timeout time reaches a certain threshold, and the preset timeout time may be reset when the producer determines that the preset timeout time is greater than the preset threshold, so as to avoid the waiting time being too long when the communication is suddenly resumed.
It should be noted that, when the producer sends the message to be sent again, the producer may continue to send the message to be sent to the same message sending node, or may send the message to any other message sending node in the message sending system, which is not limited in the present application. Optionally, the producer may further obtain the service quality of the communication connection established between the producer and each message sending node in the message sending system at the current time, and send the information to be sent through the communication connection with the highest service quality, so as to improve the message sending efficiency.
In the embodiment of the application, a producer can send a message to be sent to any node in a message sending system again when waiting for timeout, and the timeout time for waiting for message confirmation each time is increased along with the increase of the number of times of sending the message to be sent overtime, so that network congestion caused by message retransmission is avoided. When the producer sends the message to be sent, the producer numbers each message to be sent and carries the producer's identification on the message to be sent, so that the nodes in the message sending system can respectively recombine the message to be sent by each producer according to the producer's identification of the message number, and the message sending is accurate and reliable.
In order to facilitate understanding of the overall scheme provided by the embodiment of the present application, the following describes, by way of example, a message sending method provided by the embodiment of the present application with reference to a specific application scenario shown in fig. 2. For simplifying the description, only the message sending system includes only the first node and the second node, and the producer a sends the message by using the message sending system is taken as an example for description, and the implementation manners of other cases are similar to this, and are not described again.
First, a producer a establishes a communication connection with both a first node and a second node. Then, the specific steps of the producer a sending the message to the consumer are as follows:
step 1: the producer a sends the messages a1 and a3 to the first node and the message a2 to the second node according to the service quality at the sending time.
Step 2: under the influence of network conditions and the like, the first node receives the messages a1 and a3 and synchronizes the messages a1 and a3 to the second node.
And step 3: and the first node puts the messages a1 and a3 into a regrouping queue corresponding to the producer a and sorts the messages to obtain a regrouping queue { a1, a3 }. And the second node puts the messages a1 and a3 into the regrouping queue corresponding to the producer a and sorts the messages to obtain a regrouping queue { a1, a3 }.
And 4, step 4: since the initial expected message number is 1, the first node and/or the second node sends message a1 to the consumer and removes message a1 from the reassembly queue, resulting in reassembly queue { a3}, with the expected message number updated to 2.
And 5: the first node replies with a message determination corresponding to message a1 to producer a.
Step 6: when the second node receives message a2, message a2 is synchronized to the first node.
And 7: and the second node puts the message a2 into a recombination queue corresponding to the producer a for sorting to obtain a queue { a2, a3 }. And the first node puts the message a2 into a recombination queue corresponding to the producer a and sorts the recombination queue to obtain a queue { a2, a3 }.
And 8: since the expected message number is 2, the first node and/or the second node sends messages a2 and a3 to the consumer and removes messages a2 and a3 from the reassembly queue.
And step 9: the first node sends a message acknowledgment corresponding to message a3 to producer a. The second node sends a message acknowledgment corresponding to message a2 to producer a.
Example three:
based on the message sending method provided by the above embodiment, the embodiment of the present application further provides a message sending node.
Referring to fig. 9, this figure is a schematic structural diagram of a message sending node according to a third embodiment of the present application.
The message sending node provided in the embodiment of the present application is deployed in the message sending system shown in fig. 2, and the message sending system further includes at least one peer message sending node that is peer to peer with the message sending node. It will be appreciated that the message forwarding node is equally well and functionally identical to the peer message nodes, i.e. the messaging system comprises a plurality of equally well and functionally identical messaging nodes. Specifically, the message sending node includes: a receiving module 901, a synchronizing module 902 and a sending module 903;
a receiving module 901, configured to receive a first message to be sent, sent by a producer; the node is also used for receiving a second message to be sent by any peer-to-peer message sending node; the second message to be sent is sent to the peer-to-peer message sending node by the producer;
a synchronization module 902, configured to send a first message to be sent to each peer message sending node;
a sending module 903, configured to send the first message to be sent and/or the second message to be sent to the consumer.
In some possible implementation manners of the embodiment of the application, the first message to be sent and the second message to be sent carry the producer identifier and the message number; then, the message sending node may further include: a reorganization module and a sequencing module;
the recombination module is used for putting the first message to be sent into a recombination queue corresponding to the producer identifier carried by the first message to be sent and putting the second message to be sent into a recombination queue corresponding to the producer identifier carried by the second message to be sent;
and the sequencing module is used for sequencing the messages in the recombination queue according to the message numbers.
In some possible implementation manners of the embodiment of the present application, the message sending node may further include: a judging module and a response module;
the judging module is used for judging whether the message number carried by the message to be sent is an expected message number;
the sending module is specifically used for sending all messages with continuous message numbers starting from the expected message numbers in the recombination queue to the consumers and updating the expected message numbers when the judging module judges that the message numbers carried by the messages to be sent are the expected message numbers;
the initial expected message number is the minimum message number, and the updated expected message number is the next message number of the maximum message number carried by all the sent messages.
In some possible implementation manners of the embodiment of the present application, the message sending node may further include: a removal module;
and the removing module is used for removing the sent messages in the reorganization queue.
In some possible implementation manners of the embodiment of the present application, the message sending node may further include: the device comprises a searching module, a determining module and a responding module;
the searching module is used for searching the message with the source of the producer in each sent message;
the determining module is used for searching the message with the source as the producer from the searching module and determining the message with the largest message number;
and the response module is used for replying the message to determine the message to the producer according to the message number carried by the message with the largest message number determined by the determination module.
In the embodiment of the application, a plurality of message sending nodes included in the message sending system can receive a message to be sent by a producer, and synchronize to other message sending nodes in the message sending system after receiving the message to be sent by the producer so as to ensure the reliability of message sending. The identities of all message sending nodes in the message sending system are equal, a producer can send a message to be sent to any message sending node in the message sending system, a consumer can also obtain the message to be sent from any message sending node in the message sending system, even if one or more message sending nodes in the message sending system are in failure, the normal operation of the message sending system is not influenced, the influence of the active-standby switching operation of the nodes on message sending is avoided, and the risk of message sending service interruption is reduced.
Example four:
based on the message sending method and the node provided by the embodiments, a fourth embodiment of the present application further provides a message sending apparatus.
Referring to fig. 10, this figure is a schematic structural diagram of a message sending apparatus according to a fourth embodiment of the present application.
The message sending apparatus provided in the fourth embodiment of the present application is applied to a message sending system, where the message sending system includes at least two message sending nodes, for example, as shown in fig. 2. The message sending device comprises: a connection establishing module 1001, a message producing module 1002 and a message sending module 1003;
a connection establishing module 1001, configured to establish a communication connection with each message sending node in the message sending system;
a message production module 1002, configured to produce a message to be sent;
the message sending module 1003 is configured to send a message to be sent to any one message sending node in the message sending system, so that after the message sending node that receives the message to be sent synchronizes the message to be sent to other message sending nodes in the message sending system, any one or more message sending nodes in the message sending system send the message to be sent to a consumer.
In some possible implementation manners of the embodiment of the application, the message to be sent may carry the producer identifier and the message number, so that the message sending node places the message to be sent into the reassembly queue corresponding to the producer identifier carried in the message to be sent, and sorts the messages in the reassembly queue according to the message number.
In some possible implementation manners of the embodiment of the present application, the message sending apparatus may further include: a response waiting module;
and the response waiting module is used for triggering the message sending module to send the message to be sent to any message sending node in the message sending system again when the message confirmation corresponding to the message to be sent and sent by the message sending node is not received within the preset timeout.
In one example, the preset timeout time is increased in response to an increase in the number of times a message to be sent is sent.
Optionally, the message sending apparatus may further include: a time reset module;
and the time resetting module is used for resetting the preset overtime time when the preset overtime time is greater than the preset threshold value.
In some possible implementation manners of the embodiment of the present application, the message sending module 1003 may specifically include: the method comprises the steps of obtaining a submodule, a judging submodule and a sending submodule;
the obtaining submodule is used for obtaining the service quality of the communication connection established with each message sending node in the message sending system;
the judging submodule is used for judging the communication connection with the highest service quality according to the acquired service quality;
and the sending submodule is used for sending the information to be sent through the communication connection with the highest service quality judged by the judging submodule.
In some possible implementation manners of the embodiment of the present application, the obtaining the sub-module may specifically include: a first sub-module, a second sub-module, and a third sub-module;
the first submodule is used for sending a heartbeat request message to the message sending node so that the message sending node replies a heartbeat response message to a producer after receiving the heartbeat request message;
the second submodule is used for receiving a heartbeat response message replied by the message sending node;
and the third submodule is used for acquiring the service quality of the communication connection between the message sending node and the message sending node according to the heartbeat response message received by the second submodule.
In the embodiment of the application, a plurality of message sending nodes included in the message sending system can receive a message to be sent by a producer, and synchronize to other message sending nodes in the message sending system after receiving the message to be sent by the producer so as to ensure the reliability of message sending. The identities of all message sending nodes in the message sending system are equal, a producer can send a message to be sent to any message sending node in the message sending system, a consumer can also obtain the message to be sent from any message sending node in the message sending system, even if one or more message sending nodes in the message sending system are in failure, the normal operation of the message sending system is not influenced, the influence of the active-standby switching operation of the nodes on message sending is avoided, and the risk of message sending service interruption is reduced.
Example five:
based on the message sending method, the node and the device provided by the above embodiments, a fifth embodiment of the present application further provides a message sending system, which at least includes two message sending nodes provided by the above third embodiment. In some possible implementation manners of the embodiment of the present application, the system may further include a message sending apparatus provided in the fourth embodiment, and a specific structure may be as shown in fig. 2 or fig. 5.
Example six:
based on the message sending method, the node and the device provided by the foregoing embodiments, a sixth embodiment of the present application further provides a computer storage medium, where the computer storage medium is used to store a program code, and the program code is used to execute any one of the message sending methods provided by the foregoing first embodiment and second embodiment.
Example seven:
based on the message sending method, the node and the device provided by the embodiments, a seventh embodiment of the application further provides a message sending device. The message sending device includes: a processor and a memory.
The memory is used for storing program codes and transmitting the program codes to the processor;
a processor configured to execute any one of the message sending methods provided in the above first and second embodiments according to instructions in the program code.
It should be noted that, in the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. The system or the device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The foregoing is merely a preferred embodiment of the present application and is not intended to limit the present application in any way. Although the present application has been described with reference to the preferred embodiments, it is not intended to limit the present application. Those skilled in the art can now make numerous possible variations and modifications to the disclosed embodiments, or modify equivalent embodiments, using the methods and techniques disclosed above, without departing from the scope of the claimed embodiments. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application still fall within the protection scope of the technical solution of the present application without departing from the content of the technical solution of the present application.

Claims (24)

1. The message sending method is characterized by being applied to a message sending system, wherein the message sending system comprises at least two message sending nodes; the method comprises the following steps:
any message sending node in the message sending system receives a message to be sent by a producer;
the any message sending node synchronizes the message to be sent to other message sending nodes in the message sending system, so that any one or more message sending nodes in the message sending system can send the message to be sent to a consumer;
the message to be sent carries a producer identifier and a message number; after the message sending node receives the message to be sent, the method further includes: the message sending node puts the message to be sent into a recombination queue corresponding to a producer identifier carried by the message to be sent; and the message sending node sorts the messages in the recombination queue according to the message numbers.
2. The method of claim 1, wherein the message sending node sorts the messages in the reassembly queue according to the message number, and thereafter further comprising:
the message sending node judges whether the message number carried by the message to be sent is an expected message number;
when the message number carried by the message to be sent is the expected message number, the message sending node sends all messages with continuous message numbers starting from the expected message number in the recombination queue to a consumer, and updates the expected message number;
the initial expected message number is the minimum message number, and the updated expected message number is the next message number of the maximum message number carried by all the sent messages.
3. The method of claim 2, wherein the messaging node sends all messages in the reassembly queue having consecutive message numbers beginning with the expected message number to the consumer, and thereafter further comprising:
and the message sending node removes the sent messages in the reassembly queue.
4. The method of claim 2 or 3, wherein the messaging node sends all messages in the reassembly queue having consecutive message numbers beginning with the expected message number to the consumer, and thereafter further comprising:
the message sending node searches for the message which is sent by the producer and comes from each message;
determining the message with the largest message number from the messages which are found to be from the producer;
and according to the message number carried by the message with the largest determined message number, replying the message to the producer.
5. The message sending method is characterized by being applied to a message sending system, wherein the message sending system comprises at least two message sending nodes; the method comprises the following steps:
the producer establishes communication connection with each message sending node in the message sending system in advance;
the producer sends the produced message to be sent to any message sending node in the message sending system, so that after the message sending node receiving the message to be sent synchronizes the message to be sent to other message sending nodes in the message sending system, any one or more message sending nodes in the message sending system send the message to be sent to the consumer;
the message to be sent carries a producer identifier and a message number, so that the message sending node puts the message to be sent into a reassembly queue corresponding to the producer identifier carried by the message to be sent, and sorts the messages in the reassembly queue according to the message number.
6. The method of claim 5, further comprising:
and if the producer does not receive the message confirmation which is sent by the message sending node and corresponds to the message to be sent within the preset overtime, the producer sends the message to be sent to any message sending node in the message sending system again.
7. The method of claim 6,
the preset timeout time is increased according to the increase of the sending times of the message to be sent.
8. The method of claim 7, further comprising:
and when the preset timeout time is larger than a preset threshold value, resetting the preset timeout time by the producer.
9. The method according to any one of claims 5 to 8, wherein the sending, by the producer, the produced message to be sent to any one of the nodes in the message sending system specifically comprises:
the producer obtains the service quality of the communication connection established with each message sending node in the message sending system;
and the producer sends the information to be sent through the communication connection with the service quality exceeding a preset threshold value.
10. The method according to claim 9, wherein the obtaining, by the producer, the quality of service of the communication connection established with each message sending node in the message sending system specifically includes:
the producer sends a heartbeat request message to the message sending node, so that the message sending node replies a heartbeat response message to the producer after receiving the heartbeat request message;
and the producer acquires the service quality of the communication connection between the producer and the message sending node according to the received heartbeat response message.
11. A messaging node, wherein the messaging node is deployed in a messaging system, the messaging system further comprising at least one peer-to-peer messaging node that is peer-to-peer with the messaging node; the message sending node comprises: the device comprises a receiving module, a synchronization module and a sending module;
the receiving module is used for receiving a first message to be sent by a producer; the peer-to-peer message sending node is also used for receiving a second message to be sent by any one of the peer-to-peer message sending nodes; the second message to be sent is sent to the peer-to-peer message sending node by the producer;
the synchronization module is configured to send the first message to be sent to each peer message sending node;
the sending module is used for sending the first message to be sent and/or the second message to be sent to a consumer;
the first message to be sent and the second message to be sent carry producer identification and message numbers; the message sending node further comprises: a reorganization module and a sequencing module; the reassembly module is configured to place the first message to be sent into an reassembly queue corresponding to a producer identifier carried by the first message to be sent, and place the second message to be sent into an reassembly queue corresponding to a producer identifier carried by the second message to be sent; and the sequencing module is used for sequencing the messages in the recombination queue according to the message numbers.
12. The messaging node of claim 11, wherein the messaging node further comprises: a judging module and a response module;
the judging module is used for judging whether the message number carried by the message to be sent is an expected message number;
the sending module is specifically configured to send all messages with consecutive message numbers starting from the expected message number in the reassembly queue to a consumer when the judging module judges that the message number carried by the message to be sent is the expected message number, and update the expected message number;
the initial expected message number is the minimum message number, and the updated expected message number is the next message number of the maximum message number carried by all the sent messages.
13. The messaging node of claim 12, further comprising: a removal module;
and the removing module is used for removing the sent messages in the reorganization queue.
14. The messaging node according to claim 12 or 13, further comprising: the device comprises a searching module, a determining module and a responding module;
the searching module is used for searching the message which is sent and has the source of the producer;
the determining module is used for searching the messages with the source of the producer from the searching module and determining the message with the largest message number;
and the response module is used for replying the message to the producer according to the message number carried by the message with the largest message number determined by the determination module.
15. The message sending device is applied to a message sending system, and the message sending system comprises at least two message sending nodes; the device comprises: the system comprises a connection establishing module, a message production module and a message sending module;
the connection establishing module is used for establishing communication connection with each message sending node in the message sending system;
the message production module is used for producing messages to be sent;
the message sending module is configured to send the message to be sent to any one message sending node in the message sending system, so that after the message sending node that receives the message to be sent synchronizes the message to be sent to other message sending nodes in the message sending system, any one or more message sending nodes in the message sending system send the message to be sent to a consumer;
the message to be sent carries a producer identifier and a message number, so that the message sending node puts the message to be sent into a reassembly queue corresponding to the producer identifier carried by the message to be sent, and sorts the messages in the reassembly queue according to the message number.
16. The message transmission apparatus according to claim 15, further comprising: a response waiting module;
the response waiting module is configured to trigger the message sending module to send the message to be sent to any message sending node in the message sending system again when a message acknowledgement corresponding to the message to be sent and sent by the message sending node is not received within a preset timeout period.
17. The message transmission apparatus according to claim 16,
the preset timeout time is increased according to the increase of the sending times of the message to be sent.
18. The message transmission apparatus according to claim 17, further comprising: a time reset module;
the time resetting module is used for resetting the preset overtime time when the preset overtime time is larger than a preset threshold value.
19. The message sending device according to any one of claims 15 to 18, wherein the message sending module specifically includes: the method comprises the steps of obtaining a submodule, a judging submodule and a sending submodule;
the obtaining submodule is used for obtaining the service quality of the communication connection established with each message sending node in the message sending system;
the judging submodule is used for judging the communication connection with the highest service quality according to the acquired service quality;
and the sending submodule is used for sending the information to be sent through the communication connection with the highest service quality judged by the judging submodule.
20. The message sending device according to claim 19, wherein the obtaining sub-module specifically includes: a first sub-module, a second sub-module, and a third sub-module;
the first sub-module is configured to send a heartbeat request message to the message sending node, so that the message sending node replies a heartbeat response message to the producer after receiving the heartbeat request message;
the second sub-module is configured to receive a heartbeat response message replied by the message sending node;
and the third sub-module is used for acquiring the service quality of the communication connection between the message sending node and the second sub-module according to the heartbeat response message received by the second sub-module.
21. A messaging system comprising at least two messaging nodes according to any of claims 11 to 14.
22. The system according to claim 21, further comprising a messaging device according to any of claims 15 to 20.
23. A computer storage medium, characterized in that the computer-readable storage medium is configured to store program code for executing the message sending method according to any one of claims 1 to 10.
24. A message sending device, comprising a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to execute the message sending method according to any one of claims 1 to 10 according to instructions in the program code.
CN201910538329.6A 2019-06-20 2019-06-20 Message sending method, node, device, system and related equipment Active CN110225133B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910538329.6A CN110225133B (en) 2019-06-20 2019-06-20 Message sending method, node, device, system and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910538329.6A CN110225133B (en) 2019-06-20 2019-06-20 Message sending method, node, device, system and related equipment

Publications (2)

Publication Number Publication Date
CN110225133A CN110225133A (en) 2019-09-10
CN110225133B true CN110225133B (en) 2022-01-21

Family

ID=67814127

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910538329.6A Active CN110225133B (en) 2019-06-20 2019-06-20 Message sending method, node, device, system and related equipment

Country Status (1)

Country Link
CN (1) CN110225133B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112738264B (en) * 2020-12-31 2023-04-18 网络通信与安全紫金山实验室 Message middleware message transmission method and device, computer equipment and storage medium
CN112732493B (en) * 2021-03-30 2021-06-18 恒生电子股份有限公司 Method and device for newly adding node, node of distributed system and storage medium
CN113316190B (en) * 2021-05-10 2023-08-01 上海仝心电子科技有限公司 Wisdom cloud box and system

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101470636A (en) * 2007-12-27 2009-07-01 北京东方通科技发展有限责任公司 Message read-write method and apparatus
CN102857397A (en) * 2012-10-09 2013-01-02 南京国电南自电网自动化有限公司 Multi-master asynchronous duplex differential bus and communication method
CN103064731A (en) * 2012-12-26 2013-04-24 人民搜索网络股份公司 Device and method for improving message queue system performance
CN103761141A (en) * 2013-12-13 2014-04-30 北京奇虎科技有限公司 Method and device for realizing message queue
CN104679907A (en) * 2015-03-24 2015-06-03 新余兴邦信息产业有限公司 Realization method and system for high-availability and high-performance database cluster
CN104754036A (en) * 2015-03-06 2015-07-01 合一信息技术(北京)有限公司 Message processing system and processing method based on kafka
CN104753817A (en) * 2013-12-25 2015-07-01 中国移动通信集团公司 Local analogy method and local analogy system for cloud computing message queue service
CN104838374A (en) * 2012-12-06 2015-08-12 英派尔科技开发有限公司 Decentralizing a HADOOP cluster
CN105930339A (en) * 2016-03-31 2016-09-07 北京奇虎科技有限公司 Method and system for improving reliability of message transmission
CN108984320A (en) * 2018-06-27 2018-12-11 郑州云海信息技术有限公司 A kind of anti-fissure method and device of message queue cluster
CN109657005A (en) * 2018-12-10 2019-04-19 浪潮(北京)电子信息产业有限公司 A kind of data cache method of distributed cluster system, device and equipment

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101470636A (en) * 2007-12-27 2009-07-01 北京东方通科技发展有限责任公司 Message read-write method and apparatus
CN102857397A (en) * 2012-10-09 2013-01-02 南京国电南自电网自动化有限公司 Multi-master asynchronous duplex differential bus and communication method
CN104838374A (en) * 2012-12-06 2015-08-12 英派尔科技开发有限公司 Decentralizing a HADOOP cluster
CN103064731A (en) * 2012-12-26 2013-04-24 人民搜索网络股份公司 Device and method for improving message queue system performance
CN103761141A (en) * 2013-12-13 2014-04-30 北京奇虎科技有限公司 Method and device for realizing message queue
CN104753817A (en) * 2013-12-25 2015-07-01 中国移动通信集团公司 Local analogy method and local analogy system for cloud computing message queue service
CN104754036A (en) * 2015-03-06 2015-07-01 合一信息技术(北京)有限公司 Message processing system and processing method based on kafka
CN104679907A (en) * 2015-03-24 2015-06-03 新余兴邦信息产业有限公司 Realization method and system for high-availability and high-performance database cluster
CN105930339A (en) * 2016-03-31 2016-09-07 北京奇虎科技有限公司 Method and system for improving reliability of message transmission
CN108984320A (en) * 2018-06-27 2018-12-11 郑州云海信息技术有限公司 A kind of anti-fissure method and device of message queue cluster
CN109657005A (en) * 2018-12-10 2019-04-19 浪潮(北京)电子信息产业有限公司 A kind of data cache method of distributed cluster system, device and equipment

Also Published As

Publication number Publication date
CN110225133A (en) 2019-09-10

Similar Documents

Publication Publication Date Title
CN110225133B (en) Message sending method, node, device, system and related equipment
CN109039746B (en) Method for detecting bidirectional forwarding path and detecting session state and processor
US5167035A (en) Transferring messages between nodes in a network
US9608912B2 (en) Computing disjoint paths for reactive routing mesh networks
EP3547649A1 (en) Method and system for sending request for acquiring data resource
US8130676B2 (en) Method for on demand distributed hash table update
US20090164650A1 (en) Arrangement in a multi-homed transport endpoint for selecting a source address based on source-destination address pair metrics
CN110971698A (en) Data forwarding system, method and device
JP5884892B2 (en) Network system, controller, and load balancing method
US11716672B2 (en) Data transmission method, device, gateway and storage medium for mesh network
CN109587822B (en) Information transmission control method, information reception control device, and storage medium
US20130148658A1 (en) Systems and methods for scalable multicast communication using self-rooted forwarding trees
JP2014504043A (en) COMMUNICATION CONTROL SYSTEM, CONTROL DEVICE, COMMUNICATION CONTROL METHOD, AND COMMUNICATION CONTROL PROGRAM
CN109379283B (en) Ad hoc network communication method and device based on heterogeneous equipment of Internet of things and ad hoc network
US20160285969A1 (en) Ordered execution of tasks
CN110808917B (en) Multilink aggregation data retransmission method and transmitting equipment
CN106921992B (en) Method for determining wireless network connection state, client and server
US6064654A (en) Internet facsimile timing technique
JP2015198423A (en) Communication terminal and packet communication method
JP6117345B2 (en) Message system that avoids degradation of processing performance
CN112154689A (en) Communication method
CN114095465A (en) Method for realizing efficient IM message time sequence guarantee mechanism under distributed environment
US9307509B1 (en) Transmitting radio signals using simultaneous retransmission
EP3393092B1 (en) Controller coordination system for software defined networking in a wireless network with partitions
US10367708B2 (en) Network coding aware nodes in a distributed network

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