CN114760296A - Information sending method and device - Google Patents

Information sending method and device Download PDF

Info

Publication number
CN114760296A
CN114760296A CN202210217564.5A CN202210217564A CN114760296A CN 114760296 A CN114760296 A CN 114760296A CN 202210217564 A CN202210217564 A CN 202210217564A CN 114760296 A CN114760296 A CN 114760296A
Authority
CN
China
Prior art keywords
message
client
server
sent
connection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210217564.5A
Other languages
Chinese (zh)
Inventor
牛丽敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Financial Technology Co Ltd
Original Assignee
Bank of China Financial Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Financial Technology Co Ltd filed Critical Bank of China Financial Technology Co Ltd
Priority to CN202210217564.5A priority Critical patent/CN114760296A/en
Publication of CN114760296A publication Critical patent/CN114760296A/en
Pending legal-status Critical Current

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
    • 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/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • H04L67/025Protocols based on web technology, e.g. hypertext transfer protocol [HTTP] for remote control or remote monitoring of applications
    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides an information sending method and device, comprising the following steps: under the condition that a first message sent by a kafka server is received, determining a first client corresponding to the first message, and determining whether connection is established with the first client; sending a first message to the first client under the condition that the connection with the first client is determined to be established; the kafka server is connected with at least two service ends, the at least two service ends are the first service end and the second service end, the first message is a template message which is generated based on the second message and sent to the kafka server when the second service end receives the second message sent by the second client and the connection between the second service end and the first client is determined not to be established, and the information sending in the cluster environment is achieved.

Description

Information sending method and device
Technical Field
The present invention relates to the field of communications technologies, and in particular, to an information sending method and apparatus.
Background
In the scene that the server is a single node, the client a establishes a long connection with the server S through a full duplex communication Protocol WebSocket based on a Transmission Control Protocol (TCP), and the server S records the connection condition. After receiving the message sent by other clients, for example, B, the server S forwards the message to the client a in real time if the server S and a are connected at this time.
However, if the server is in a cluster environment, i.e. a multi-node environment, a scenario may occur in which a is connected to the server but cannot receive the message sent by B: the client A establishes long connection with the server S1 through WebSocket, and the server S records the connection condition. After the server S2 receives the message from another client, for example, B, since the connection information is recorded in S1, S2 cannot inquire the connection record of a, and cannot send the message to a in real time.
Therefore, a problem that a message cannot be sent to a target client when a receiving client of the message and a sending client of the message are not connected to the same service end node in a cluster environment is needed to be solved.
Disclosure of Invention
The invention provides an information sending method and device, which are used for solving the defect that messages in a cluster environment cannot be sent to a target client in the prior art and realizing the sending of the messages in the cluster environment.
The invention provides an information sending method, which is applied to a first service end and comprises the following steps:
under the condition of receiving a first message sent by a kafka server, determining a first client corresponding to the first message, and determining whether connection is established with the first client;
sending the first message to the first client if it is determined that a connection has been established with the first client;
the kafka server is connected with at least two service terminals, wherein the at least two service terminals comprise the first service terminal and a second service terminal;
the first message is a template message which is generated and sent to the kafka server based on a second message when the second server receives the second message sent by a second client and determines that the second server and the first client do not establish connection.
The invention also provides an information sending method, which is applied to a kafka server, wherein the kafka server is connected with at least two service terminals, the at least two service terminals comprise a second service terminal, and the method comprises the following steps:
under the condition of receiving a first message sent by a second server, sending the first message to other servers except the second server in the at least two servers;
the first message is generated by the second server side when the second server side receives a second message sent by a second client side and determines that the second server side and a first client side corresponding to the second message are not connected, and the first message is sent to the kafka server.
The present invention also provides an information transmitting apparatus, comprising:
the message processing module is used for determining a first client corresponding to a first message under the condition that the first message sent by the kafka server is received, and determining whether connection with the first client is established or not;
a message sending module, configured to send the first message to the first client when it is determined that a connection has been established with the first client;
the kafka server is connected with at least two service terminals, and the at least two service terminals comprise a first service terminal and a second service terminal;
the first message is a template message which is generated and sent to the kafka server based on a second message when the second server receives the second message sent by a second client and determines that the second server and the first client do not establish connection.
The present invention also provides an information transmitting apparatus, comprising:
the sending module is used for sending a first message to other service terminals except the second service terminal in the at least two service terminals under the condition of receiving the first message sent by the second service terminal;
the first message is generated by the second server side when the second server side receives a second message sent by a second client side and determines that the second server side and a first client side corresponding to the second message are not connected, and the first message is sent to the kafka server.
The present invention also provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the information transmission method as described in any one of the above.
The present invention also provides a non-transitory computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the information transmitting method as described in any of the above.
The invention also provides a computer program product comprising a computer program which, when executed by a processor, implements the method of transmitting information as described in any one of the above.
The information sending method and the device provided by the invention connect at least two service terminals including a first service terminal and a second service terminal through the kafka server, the second service terminal receives a second message sent by a second client terminal, and determines that the first client does not establish a connection with a receiving end of the second message, generates a first message based on the second message, and sending the first message to the kafka server, the first server determines a first client corresponding to the first message under the condition that the first server receives the first message sent by the kafka server, sending the first message to the first client upon determining to establish a connection with the first client, under the condition that the first client and the second client are not connected to the same server, the first client can still receive the message sent by the second client, and information sending in the cluster environment is achieved.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a schematic flow chart of a method for sending information according to the present invention;
FIG. 2 is a schematic diagram illustrating a connection relationship between nodes in a cluster environment according to the related art;
FIG. 3 is a schematic diagram of a connection relationship between nodes in a cluster environment provided by the present invention;
fig. 4 is a schematic flow chart of a server receiving a message sent by a client according to the present invention;
fig. 5 is a second schematic flow chart of the information sending method provided by the present invention;
FIG. 6 is a schematic structural diagram of an information transmitting apparatus according to the present invention;
FIG. 7 is a second schematic structural diagram of an information transmitting apparatus according to the present invention;
fig. 8 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. 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 invention.
Fig. 1 is a flowchart of an information sending method according to an embodiment of the present invention, and as shown in fig. 1, the information sending method is applied to a first service end, and includes step 100 and step 101.
Step 100, under the condition that a first message sent by a kafka server is received, determining a first client corresponding to the first message, and determining whether a connection is established with the first client.
The first message corresponds to the first client, which means that the receiving end designated by the first message is the first client.
The kafka server is connected with at least two service terminals, and the at least two service terminals comprise a first service terminal and a second service terminal.
The first message is a template message which is generated and sent to the kafka server based on the second message when the second server receives the second message sent by the second client and determines that the second server and the first client do not establish connection.
Optionally, a WebSocket connection is established between the second server and the second client.
The WebSocket is a part of HyperText Markup Language (HTML 5) specification, and provides full-duplex service between a World Wide Web (Web) application client and a service end. The method can be used for scenes such as message broadcasting, social subscription, collaborative editing and the like.
As shown in fig. 2, in the related art, when the second server receives the message sent by the second client, if the receiving end of the message is the first client and the second server does not establish a connection with the first client, the message cannot be sent to the first client.
As shown in fig. 3, in the embodiment of the present application, at least two servers are connected through a kafka server, and an example in which the kafka server is connected to two servers is shown in the figure.
Under the condition that the second server receives the second message sent by the second client, because the receiving end corresponding to the second message is the first client, but the second server only establishes connection with the second client and does not establish connection with the first client, under the condition, the second server generates the first message according to the received second message and sends the first message to the kafka server.
It should be noted that the first message is a template message sent to the kafka server, and the parameters of the template message at least include: topic, user identity userId and message content.
The userId is an ID number of a target user, that is, a receiving end of the message, for example, an ID number of a first client, and it should be noted that the ID number is a unique identifier of the client, and the ID numbers of the clients are different; topic is a necessary parameter for sending kafka messages, and here topic can fill in a fixed value uniformly.
After receiving the first message sent by the second server, the kafka server forwards the first message to other servers connected with the kafka server. That is, the first server may be any one other than the second server to which the kafka server is connected.
Under the condition that the first server receives the first message sent by the kafka server, the first server determines a receiving end corresponding to the first message, namely the first client, based on the parameters in the first message.
The first service end determines whether the first service end establishes connection with a receiving end corresponding to the first message.
Step 101, sending the first message to the first client under the condition that the connection with the first client is established.
Optionally, a WebSocket connection is established between the first service end and the first client, and the first service end sends the first message to the first client when determining that the first service end is connected to the first client. And the first service end does not process under the condition of determining to establish connection with the first client end.
The information sending method provided by the embodiment of the application connects at least two service ends including a first service end and a second service end through a kafka server, the second service end receives a second message sent by a second client, and determines that the first client does not establish a connection with a receiving end of the second message, generates a first message based on the second message, and sending the first message to the kafka server, the first server determines a first client corresponding to the first message under the condition that the first server receives the first message sent by the kafka server, sending the first message to the first client upon determining to establish a connection with the first client, under the condition that the first client and the second client are not connected to the same server, the first client can still receive the message sent by the second client, and information sending in the cluster environment is achieved.
As shown in fig. 4, in some embodiments, the information sending method further includes: step 400, step 401 and step 402.
Step 400, storing a third message sent by a third client in a message table when the third message is received.
And the first service end receives a third message sent by the third client end, which shows that the connection between the first service end and the third client end is established.
The message table is used for storing messages sent by the client, and comprises fields for recording message states, wherein the states of each message, including a read state and an unread state, are recorded in the fields. The messages in the read state are sent to the corresponding client side, and the messages in the unread state are not sent to the corresponding client side.
And under the condition that the first server side receives a third message sent by the third client side, the third message is stored in a message table, the default of the message in the message table is an unread state, and the message in the message table is changed into a read state after the third message is sent successfully.
Step 401, determining a fourth client corresponding to the third message, and determining whether a connection has been established with the fourth client.
It is to be understood that the third message corresponds to the fourth client, which means that the receiving end indicated by the third message is the fourth client. The first service end determines whether the first service end has established connection with the receiving end indicated by the third message.
Optionally, it may be searched from the local MAP, whether a userId corresponding to the fourth client exists or not, and if so, it indicates that the first server establishes a connection with the fourth client, and if not, it indicates that the first server does not establish a connection with the fourth client,
step 402, under the condition that the connection with the fourth client is determined to be established, sending the third message to the fourth client, and marking the state of the third message in the message table as read.
And under the condition that the first server side is connected with the fourth client side, the first server side sends the third message to the fourth client side, and marks the state of the third message in the message table as read, so that the third message is prevented from being sent repeatedly.
Sending a fourth message to the kafka server based on the third message if it is determined that the connection is not established with the fourth client.
Optionally, the fourth message is a template message sent to the kafka server, and is generated by the first service end based on the third message. The parameters of the fourth message include at least: subject matter, user identification, and message content.
In an instance in which it is determined that a connection is not established with the fourth client, a fourth message in a message table is in an unread state.
After receiving the fourth message, the kafka server forwards the fourth message to other servers except the first server, which establish a connection with the kafka server.
And after receiving the fourth message, the other service terminals determine whether to establish connection with the receiving terminal of the fourth message, if so, the other service terminals send the fourth message to the receiving terminal of the fourth message, and mark the fourth message in the message table as a read state.
According to the information sending method provided by the embodiment of the application, the server side records the received message into the message table, sends the message to the message receiving side under the condition that the connection with the message receiving side is confirmed, marks the state of the message in the message table to be the read state, and sends the template message to the kafka server based on the message under the condition that the connection with the message receiving side is not confirmed, so that the server side can reach the connection node of the target client side after sending the message to the kafka server at most once, and the information sending in the cluster environment is realized.
In some embodiments, the method further includes, in the case that it is monitored that the connection is established with the third client, two processing steps, specifically including:
under the condition of establishing connection with the third client, storing the connection record of the third client to a local memory;
optionally, after monitoring that the user is online at the third client, the first server records the WebSocket long connection condition with the third client on a local MAP of the first server. The data format in the MAP may be: [ key, value ], where key is the userId of the user and value is the connection session.
The session refers to a connection session of WebSocket in the present application. After the WebSocket client is connected with the server, the server stores a globally unique session data structure, and WebSocket messages are transmitted through the session. And after the connection is disconnected, the session data structure is automatically released.
When the connection record of the third client is stored in the local memory, the message can be successfully sent to the third client when the message of which the receiving end is the third client is received.
Determining whether a fifth message exists in the message table, wherein the fifth message corresponds to the third client and has an unread state;
sending the fifth message to the third client if the fifth message is present in the message table.
Before the first server establishes connection with the third client, all servers in the cluster system may not establish connection with the third client, and therefore, the message table has a message whose receiving end is the third client and whose state is unread.
Therefore, when the first service end establishes a connection with the third client, it is necessary to determine whether a fifth message corresponding to the third client and having an unread status exists in the message table, and if so, send the fifth message to the third client.
Optionally, the fifth message may be sent to the third client through a connection session between the first server and the third client.
It should be noted that, any one of the connection establishment with the client and the server may perform the connection state record and the message processing by using the two processing steps.
According to the information sending method provided by the embodiment of the application, the server stores the connection record in the local memory under the condition that the server monitors the connection with the client, the message can be successfully sent when the message with the third client as the receiving end is received, in addition, the message with the third client as the receiving end and the unread state in the message table is sent to the third client, the unread message is processed, and the information sending in the cluster environment is realized.
In some embodiments, the method further comprises:
and under the condition that the connection with the third client is monitored to be disconnected, removing the connection record of the third client from the local memory.
It should be noted that, when any client is disconnected from the server, the connection record of the client needs to be removed from the local memory of the server.
And the disconnected client is removed from the local memory, so that the information of the client with the established connection is ensured to be stored in the local memory, and the effectiveness of the information is ensured.
Fig. 5 is a second schematic flowchart of the information sending method according to the second embodiment of the present invention, and is applied to a kafka server, where the kafka server is connected to at least two servers, and the at least two servers include a second server.
Because the kafka server is used as kafka message middleware, each WebSocket node takes the IP address of the host as the groupID, namely each node is an independent group, and each message can be consumed by all nodes.
When the system is started, each service end node is connected to the kafka server as a consumer. The groupID in the connection parameters is an Internet address (Internet protocol, IP) of a server where the node is located, and because the IP of each server is different, each message is guaranteed to reach all nodes certainly, and the situation that the node cannot receive the message is avoided.
It should be noted that group is the scalable and capacity-expandable consumer mechanism provided by kafka. The same group shares a groupID, and each message can be consumed by consumers in the same group.
As shown in fig. 5, the message sending method is applied to the kafka server, and includes step 500.
Step 500, in a case of receiving a first message sent by a second server, sending the first message to other servers except the second server in the at least two servers;
the first message is generated by the second server when the second server receives a second message sent by a second client and determines that the second server is not connected with a first client corresponding to the second message, and the first message is sent to the kafka server.
The first message is a template message sent by the second server to the kafka server, and the parameters of the template message at least include: subject matter, user identification, and message content. The meaning of each parameter is the same as that of the parameter in step 100, and is not described herein again.
It can be understood that, when the kafka server receives the first message sent by the second server, it indicates that the second server does not establish a connection with the receiving end of the first message, that is, the first client, at this time, the state of the first message in the message table is an unread state.
And the kafka server sends the first message to the servers except the second server in the servers connected with the kafka server.
For example, the kafka server is connected with the first server, the second server, and the third server, and the kafka server sends the first message to the first server and the third server when receiving the first message sent by the second server.
The first server and the third server may or may not establish a connection with the receiving end of the first message.
Under the condition that the first service end establishes connection with a receiving end of the first message, the first service end sends the first message to the receiving end of the first message, and marks the first message in the message table as a read state; or, in the case that the third server establishes a connection with the receiving end of the first message, the third server sends the first message to the receiving end of the first message, and marks the first message in the message table as a read state.
And under the condition that the first service end and the third service end are connected with the receiving end of the first message, the state of the first message in the message table is still in an unread state until the first service end or the third service end is connected with the receiving end of the first message, and the first service end or the third service end sends the first message in the message table to the receiving end of the first message. So far, after the first message is sent, the server side needs to send the message to the kafka server at most once, and the message receiver can receive the message only by establishing connection with the server side connected with any one kafka server.
The information transmitting apparatus provided by the present invention is described below, and the information transmitting apparatus described below and the information transmitting method described above may be referred to in correspondence with each other.
As shown in fig. 6, information transmitting apparatus 600 includes: a message processing module 610 and a message sending module 620.
The message processing module 610 is configured to, in a case that a first message sent by a kafka server is received, determine a first client corresponding to the first message, and determine whether a connection has been established with the first client;
a message sending module 620, configured to send the first message to the first client if it is determined that a connection has been established with the first client;
the kafka server is connected with at least two service terminals, and the at least two service terminals comprise a first service terminal and a second service terminal;
the first message is a template message which is generated and sent to the kafka server based on a second message when the second server receives the second message sent by a second client and determines that the second server does not establish connection with the first client.
Optionally, the message processing module 610 is further configured to, in a case that a third message sent by a third client is received, store the third message in a message table;
determining a fourth client corresponding to the third message, and determining whether a connection is established with the fourth client;
the message sending module 620 is further configured to send the third message to the fourth client and mark the status of the third message in the message table as read when it is determined that the connection with the fourth client is established; alternatively, the first and second electrodes may be,
in a case where it is determined that a connection is not established with the fourth client, generating a fourth message based on the third message, and sending the fourth message to the kafka server.
Optionally, the information sending apparatus 600 further includes a connection module, configured to store the connection record of the third client in a local memory when it is monitored that the connection with the third client is established;
determining whether a fifth message exists in the message table, wherein the fifth message corresponds to the third client and has an unread state;
sending the fifth message to the third client if the fifth message exists in the message table.
Optionally, the fourth message is a template message sent by the first service end to the kafka server, and the parameters of the fourth message at least include: subject matter, user identification, and message content.
An embodiment of the present invention further provides an information sending apparatus, as shown in fig. 7, an information sending apparatus 700 includes:
a sending module 710, configured to send a first message sent by a second server to other servers except the second server in the at least two servers when the first message is received;
the first message is generated by the second server side when the second server side receives a second message sent by a second client side and determines that the second server side and a first client side corresponding to the second message are not connected, and the first message is sent to the kafka server.
Fig. 8 illustrates a physical structure diagram of an electronic device, and as shown in fig. 8, the electronic device may include: a processor (processor)810, a communication Interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication Interface 820 and the memory 830 communicate with each other via the communication bus 840. Processor 810 may invoke logic instructions in memory 830 to perform a method of transmitting information, the method comprising: under the condition of receiving a first message sent by a kafka server, determining a first client corresponding to the first message, and determining whether connection is established with the first client;
sending the first message to the first client if it is determined that a connection has been established with the first client;
the kafka server is connected with at least two service terminals, and the at least two service terminals comprise a first service terminal and a second service terminal;
the first message is a template message which is generated and sent to the kafka server based on a second message when the second server receives the second message sent by a second client and determines that the second server and the first client do not establish connection;
alternatively, the method comprises: under the condition of receiving a first message sent by a second server, sending the first message to other servers except the second server in the at least two servers;
the first message is generated by the second server side when the second server side receives a second message sent by a second client side and determines that the second server side and a first client side corresponding to the second message are not connected, and the first message is sent to the kafka server.
In addition, the logic instructions in the memory 830 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, the computer program product including a computer program, the computer program being storable on a non-transitory computer-readable storage medium, the computer program being capable of executing, when executed by a processor, the information transmission method provided by the above methods, the method including: under the condition of receiving a first message sent by a kafka server, determining a first client corresponding to the first message, and determining whether connection is established with the first client;
sending the first message to the first client if it is determined that a connection has been established with the first client;
the kafka server is connected with at least two service terminals, and the at least two service terminals comprise a first service terminal and a second service terminal;
the first message is a template message which is generated and sent to the kafka server based on a second message when the second server receives the second message sent by a second client and determines that the second server does not establish connection with the first client;
alternatively, the method comprises: under the condition of receiving a first message sent by a second server, sending the first message to other servers except the second server in the at least two servers;
the first message is generated by the second server side when the second server side receives a second message sent by a second client side and determines that the second server side and a first client side corresponding to the second message are not connected, and the first message is sent to the kafka server.
In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, the computer program being implemented by a processor to perform the method for transmitting information provided by the above methods, the method comprising: under the condition of receiving a first message sent by a kafka server, determining a first client corresponding to the first message, and determining whether connection is established with the first client;
sending the first message to the first client if it is determined that a connection has been established with the first client;
the kafka server is connected with at least two service terminals, and the at least two service terminals comprise a first service terminal and a second service terminal;
the first message is a template message which is generated and sent to the kafka server based on a second message when the second server receives the second message sent by a second client and determines that the second server and the first client do not establish connection;
alternatively, the method comprises: under the condition of receiving a first message sent by a second server, sending the first message to other servers except the second server in the at least two servers;
the first message is generated by the second server side when the second server side receives a second message sent by a second client side and determines that the second server side and a first client side corresponding to the second message are not connected, and the first message is sent to the kafka server.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, and not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. An information sending method, applied to a first service end, includes:
under the condition of receiving a first message sent by a kafka server, determining a first client corresponding to the first message, and determining whether connection is established with the first client;
sending the first message to the first client if it is determined that a connection has been established with the first client;
the kafka server is connected with at least two service terminals, and the at least two service terminals comprise a first service terminal and a second service terminal;
the first message is a template message which is generated and sent to the kafka server based on a second message when the second server receives the second message sent by a second client and determines that the second server and the first client do not establish connection.
2. The method according to claim 1, further comprising:
under the condition of receiving a third message sent by a third client, storing the third message into a message table;
determining a fourth client corresponding to the third message, and determining whether connection with the fourth client is established;
under the condition that the connection with the fourth client side is determined to be established, sending the third message to the fourth client side, and marking the state of the third message in the message table as read; alternatively, the first and second electrodes may be,
in a case where it is determined that a connection is not established with the fourth client, generating a fourth message based on the third message, and sending the fourth message to the kafka server.
3. The method of claim 2, further comprising:
storing the connection record of the third client into a local memory under the condition that the connection with the third client is monitored;
determining whether a fifth message exists in the message table, wherein the fifth message corresponds to the third client and has an unread state;
sending the fifth message to the third client if the fifth message exists in the message table.
4. The information sending method according to claim 2, wherein the fourth message is a template message sent by the first service end to the kafka server, and the parameters of the fourth message at least include: subject matter, user identification, and message content.
5. An information sending method is applied to a kafka server, wherein the kafka server is connected with at least two service sides, and the at least two service sides include a second service side, and the method includes:
under the condition of receiving a first message sent by a second server, sending the first message to other servers except the second server in the at least two servers;
the first message is generated by the second server side when the second server side receives a second message sent by a second client side and determines that the second server side and a first client side corresponding to the second message are not connected, and the first message is sent to the kafka server.
6. An information transmission apparatus, comprising:
the message processing module is used for determining a first client corresponding to a first message under the condition that the first message sent by the kafka server is received, and determining whether connection with the first client is established or not;
a message sending module, configured to send the first message to the first client when it is determined that a connection has been established with the first client;
the kafka server is connected with at least two service terminals, wherein the at least two service terminals comprise the first service terminal and a second service terminal;
the first message is a template message which is generated and sent to the kafka server based on a second message when the second server receives the second message sent by a second client and determines that the second server and the first client do not establish connection.
7. An information transmission apparatus, comprising:
the sending module is used for sending a first message to other service terminals except the second service terminal in the at least two service terminals under the condition of receiving the first message sent by the second service terminal;
the first message is generated by the second server when the second server receives a second message sent by a second client and determines that the second server is not connected with a first client corresponding to the second message, and the first message is sent to the kafka server.
8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the program implements the method according to any one of claims 1 to 4 or implements the method according to claim 5.
9. A non-transitory computer-readable storage medium having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the information transmitting method according to any one of claims 1 to 4 or implements the information transmitting method according to claim 5.
10. A computer program product comprising a computer program, wherein the computer program when executed by a processor implements the information transmission method according to any one of claims 1 to 4 or implements the information transmission method according to claim 5.
CN202210217564.5A 2022-03-07 2022-03-07 Information sending method and device Pending CN114760296A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210217564.5A CN114760296A (en) 2022-03-07 2022-03-07 Information sending method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210217564.5A CN114760296A (en) 2022-03-07 2022-03-07 Information sending method and device

Publications (1)

Publication Number Publication Date
CN114760296A true CN114760296A (en) 2022-07-15

Family

ID=82325589

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210217564.5A Pending CN114760296A (en) 2022-03-07 2022-03-07 Information sending method and device

Country Status (1)

Country Link
CN (1) CN114760296A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110611691A (en) * 2018-06-15 2019-12-24 中兴通讯股份有限公司 Message pushing method, system and storage medium
CN110798495A (en) * 2018-08-03 2020-02-14 北京京东尚科信息技术有限公司 Method and server for end-to-end message push in cluster architecture mode
CN111083193A (en) * 2019-11-11 2020-04-28 厦门网宿有限公司 Long connection message sending method, server and storage medium
CN112087475A (en) * 2019-06-13 2020-12-15 北京东土科技股份有限公司 Message pushing method and device for cloud platform component application and message server

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110611691A (en) * 2018-06-15 2019-12-24 中兴通讯股份有限公司 Message pushing method, system and storage medium
CN110798495A (en) * 2018-08-03 2020-02-14 北京京东尚科信息技术有限公司 Method and server for end-to-end message push in cluster architecture mode
CN112087475A (en) * 2019-06-13 2020-12-15 北京东土科技股份有限公司 Message pushing method and device for cloud platform component application and message server
CN111083193A (en) * 2019-11-11 2020-04-28 厦门网宿有限公司 Long connection message sending method, server and storage medium

Similar Documents

Publication Publication Date Title
CN108476165B (en) Information interaction method, client and device
CN111083161A (en) Data transmission processing method and device and Internet of things equipment
KR102208935B1 (en) Messaging api over http protocol to establish context for data exchange
CN111917562B (en) Broadcast message forwarding method, device, equipment and storage medium
CN111541555A (en) Group chat optimization method and related product
CN106411713B (en) State notification method and server
CN110971873B (en) Real-time monitoring method, monitoring system and storage medium
CN114760296A (en) Information sending method and device
CN107733979B (en) Data pushing method, server and system
CN114025005B (en) Data communication method, system, electronic equipment and storage medium
CN116308671A (en) Online bidding method based on MQTT protocol, electronic equipment and storage medium
CN109120578B (en) Method and device for realizing link connection processing
CN113225247B (en) Group chat processing method and system, electronic device and computer readable storage medium
US10108588B2 (en) Method and system for communicating between client pages
CN109041038A (en) For controlling the method and system of electronic device and designated user's binding
CN114124935A (en) Method, system, equipment and storage medium for realizing FTP service
CN106453573A (en) Method and system for processing CGI request in HTTP server
CN113037803A (en) Geological disaster monitoring method and system, electronic equipment and storage medium
CN112291164A (en) Repeated registration processing method, computer device and readable storage medium
CN114257630B (en) Classroom real-time interaction method, system, terminal equipment and readable storage medium
CN112448952B (en) Method and device for remotely receiving and storing intelligent equipment parameters
CN111274066B (en) Data backup method, device and system
CN114125017B (en) Media information display method and device, storage medium and electronic equipment
CN110460586B (en) In-vehicle node communication method, device, equipment and storage medium
CN112449312B (en) Method and device for acquiring multimedia mass-sending service group members in broadband cluster system

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