Disclosure of Invention
In view of the foregoing, it is desirable to provide a method, system, device and storage medium for processing a real-time message.
A real-time message processing method, comprising the steps of: the method comprises the steps that an APP client receives first information pushed by a netty program module through UDP connection, the first information is analyzed and presented, and the first information carries a first label; receiving a second message input by a user, determining a target receiving end according to the first label, and encapsulating the second message and the target receiving end to obtain a second message packet; sending the second message packet to a netty program module, and sending the second message packet to a rabbitmq queue through a first channel; the rabbitmq queue analyzes the second message packet to obtain a target receiving end, and the second message packet is sent to a nodejs program module through a second channel; and the nodejs program module analyzes the second message packet, acquires a second message and sends the second message to a target receiving end through TCP connection.
In one embodiment, before the APP client receives the first information pushed by the netty program module through the UDP connection, the method further includes: the small program client receives a first message, packages the first message, acquires a first message packet, and sends the first message packet to the nodejs program module; the nodejs program module transmits the first message packet to the rabbitmq queue through a second channel; the rabbitmq queue analyzes the first message packet, a target sending end is obtained, and the first message packet is sent to a netty program module through a first channel; and the netty program module analyzes the first message packet, acquires a first message and sends the first message to a target sending end through UDP connection.
In one embodiment, before the nodejs program module transmits the first message packet to the rabbitmq queue through the second channel, the method further includes: after the nodejs program module receives the first message packet, judging whether the nodejs program module is connected with a second channel of the rabbitmq queue; if the second channel is connected, transmitting a first message packet to the rabbitmq queue through the second channel; if the second channel is disconnected, the second channel is reconnected through a heartbeat program, and after the reconnection is completed, the first message packet is transmitted to the rabbitmq queue through the second channel.
In one embodiment, the reconnecting the second channel through the heartbeat procedure specifically includes: requesting a second channel through a domain name, a port, a designated account, and a password of the rabbitmq queue; a connection request is carried out through a standard protocol, and the connection between the nodejs program module and the second channel is established; and returning a prompt that the nodejs program module is successfully connected with the second channel.
In one embodiment, the receiving a second message input by a user, determining a target receiving end according to the first tag, encapsulating the second message and the target receiving end, and acquiring a second message packet specifically includes: acquiring a local configuration file, and acquiring a server domain name and port information according to the local configuration file; and calling an encapsulation code module, and encapsulating the second message and the target receiving end according to the server domain name and the port information to obtain a second message packet.
In one embodiment, before the sending the second message packet to the netty program module and sending the second message packet to the rabbitmq queue through the first channel, the method further includes: after receiving the second message packet, the netty program module judges whether the netty program module is connected with a first channel of a rabbitmq queue; if the first channel is connected, sending the second message packet to the rabbitmq queue through the first channel; if the first channel is disconnected, the first channel is reconnected through a heartbeat program, and after the reconnection is completed, the second message packet is sent to the rabbitmq queue through the first channel.
In one embodiment, the reconnecting the first channel through the heartbeat procedure specifically includes: requesting a first channel through a domain name, a port, a designated account and a password of a rabbitmq queue; performing a connection request through a standard protocol, and establishing connection between the netty program module and the first channel; and returning a prompt that the connection between the netty program module and the first channel is successful.
A real-time message processing system, comprising: a netty program module, a code packaging module, a rabbitmq queue and a nodejs program module; the netty program module is used for receiving first information pushed by the netty program module through UDP connection, analyzing and presenting the first information; the code encapsulation module is used for receiving a second message input by a user, determining a target receiving end according to the first label, and encapsulating the second message and the target receiving end to obtain a second message packet; the netty program module is further configured to send the second message packet to a rabbitmq queue through a first channel when the second message packet is sent to the netty program module; the rabbitmq queue is used for analyzing the second message packet, acquiring a target receiving end, and sending the second message packet to a nodejs program module through a second channel; and the nodejs program module is used for analyzing the second message packet, acquiring a second message and sending the second message to a target receiving end through TCP connection.
An apparatus comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of a real-time message processing method as described in the various embodiments above when executing the program.
A storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of a real-time message processing method as described in the various embodiments above.
Compared with the prior art, the invention has the advantages and beneficial effects that: the invention can connect the APP client and the applet client, realizes cross-platform real-time message intercommunication, improves the real-time performance and reliability of message processing and improves the user experience.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings by way of specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In one embodiment, as shown in fig. 1, there is provided a real-time message processing method, including the steps of:
step S101, the APP client receives a first message pushed by the netty program module through UDP connection, analyzes and presents the first message, and the first message carries a first tag.
Specifically, after a client sends a first message to an APP client through an applet client, a netty program module pushes the first message to the APP client through UDP connection, the APP client analyzes and presents the first message, the first message carries a first tag, and the first tag may be a client ID.
And step S102, receiving a second message input by a user, determining a target receiving end according to the first label, and encapsulating the second message and the target receiving end to obtain a second message packet.
Specifically, after receiving a first message of a client, a user, such as a business consultant or a sales manager, replies to the first message, that is, inputs a second message, determines a target receiving end according to a first tag, encapsulates the second message and the target receiving end, and obtains a second message packet. The target receiving end is an applet client.
At this time, the APP client serves as a message sending end, and can establish connection with the netty program module through the UDP protocol through the encapsulated code module by using the server domain name and the port information configured in the local configuration file, and send the second message packet to the netty program module.
Step S103, sending the second message packet to the netty program module, and sending the second message packet to the robbitmq queue through the first channel.
Specifically, after the APP client sends the second message packet to the netty program module, the netty program module sends the second message packet to the rabbitmq queue through the first channel connected to the rabbitmq queue.
And step S104, the rabbitmq queue analyzes the second message packet to obtain a target receiving end, and the second message packet is sent to the nodejs program module through the second channel.
Specifically, after the rabbitmq queue receives the second message packet, the rabbitmq queue analyzes the second message packet to obtain a target receiving end, and the target receiving end is connected with the nodejs program module through a second channel to send the second message packet to the nodejs program module.
And step S105, the nodejs program module analyzes the second message packet, acquires the second message and sends the second message to the target receiving end through TCP connection.
Specifically, the nodejs program module analyzes the second message packet, acquires the second message, and sends the second message to the target receiving end through the TCP connection, and the target receiving end presents the content of the second message to complete the real-time message sending.
In this embodiment, the APP client receives a first message pushed by the netty program module through UDP connection, analyzes and presents the first message, where the first message carries a first tag, and the first tag corresponds to a small program message sending end; receiving a second message input by an APP client user, determining a target receiving end according to the first label, and encapsulating the second message and the target receiving end to obtain a second message packet; the second message packet is sent to the netty program module, the second message packet is sent to the rabbitmq queue through the first channel, the second message packet is analyzed through the rabbitmq queue, a target receiving end is obtained, the second message packet is sent to the nodejs program module through the second channel, the nodejs program module analyzes the second message packet, the second message is obtained, the second message is sent to the target receiving end through TCP connection, the APP client and the applet client can be connected, cross-platform real-time message intercommunication is achieved, the real-time performance and the reliability of message processing are improved, and user experience is improved.
Specifically, in this embodiment, an APP client is used as a sending end of a message, the APP client inputs a second message and transmits the second message to the netty program module, the netty program module sends the second message to the nodejs program module through a rabbitmq queue, and the nodejs program module sends the second message to the applet client, so that the message sending from the APP client to the applet client is realized. However, the applet client may also be used as a sending end of the message, the applet client inputs the first message and transmits the first message to the nodejs program module, the nodejs program module sends the first message to the netty program module through the rabbitmq queue, and the netty program module sends the first message to the APP client, so that the message sending from the applet client to the APP client is realized. By the two modes, the real-time message intercommunication between the APP client and the applet client is realized.
Before step S101, the method further includes: the small program client receives the first message, packages the first message, acquires a first message packet, and sends the first message packet to the nodejs program module; the nodejs program module transmits the first message packet to a rabbitmq queue through a second channel; the rabbitmq queue analyzes the first message packet, a target sending end is obtained, and the first message packet is sent to the netty program module through the first channel; the netty program module analyzes the first message packet, acquires a first message, and sends the first message to the target sending end through UDP connection.
Specifically, at this time, the applet client serves as a message sending end, and the first message can be encapsulated into a first message packet through the encapsulation code module by using the server domain name and the port information configured in the configuration file; and establishing connection with the nodejs program module through a TCP protocol, and sending the first message packet to the nodejs program module. And after receiving the first message packet, the nodejs program module transmits the first message packet to a rabbitmq queue through the second channel, analyzes the first message packet through the rabbitmq queue to obtain a target sending end, sends the first message packet to the netty program module through the first channel, analyzes the first message packet through the netty program module to obtain a first message, and sends the first message to the target sending end through UDP connection. The target sending terminal is the APP client.
After the nodejs program module receives the first message packet, before the nodejs program module transmits the first message packet to the rabbitmq queue through the second channel, the method further includes: judging whether the nodejs program module is connected with the second channel of the rabbitmq queue; if the second channel is connected, transmitting the first message packet to a rabbitmq queue through the second channel; if the second channel is disconnected, the second channel is reconnected through a heartbeat program, and the first message packet is transmitted to the rabbitmq queue through the second channel after the reconnection is finished.
Specifically, after receiving the first message packet, the nodejs program module needs to detect whether the second channel of the rabbitmq queue is connected or not; after the connection with the second channel is determined, transmitting the first message packet to a rabbitmq queue through the second channel; and if the connection between the first channel and the second channel is not connected, reestablishing the connection between the nodejs program module and the second channel through a heartbeat program, and sending the first message packet to a rabbitmq queue through the second channel after the establishment is finished.
Wherein, reconnect the second channel through the heartbeat procedure, specifically include: requesting a second channel through the domain name, port, designated account and password of the rabbitmq queue; a connection request is carried out through a standard protocol, and the connection between the nodejs program module and the second channel is established; and returning a prompt that the nodejs program module is successfully connected with the second channel.
Specifically, the heartbeat program requests the second channel through the domain name, the port, the designated account and the password of the rabbitmq queue, the connection between the second channel and the nodejs program module is completed through a standard protocol IEEE802.11, after the connection, a prompt of successful connection is returned, and then data transmission between the nodejs program module and the rabbitmq queue is realized through the second channel.
Wherein, step S102 specifically includes: acquiring a local configuration file, and acquiring a server domain name and port information according to the local configuration file; and calling an encapsulation code module, and encapsulating the second message and the target receiving end according to the server domain name and the port information to obtain a second message packet.
Specifically, after the second message and the target receiving terminal are obtained, a local configuration file is obtained, the server domain name and the port information are obtained according to the local configuration file, the second message, the target receiving terminal, the server domain name and the port information are packaged through a packaging code module, a second message packet is obtained, and subsequent transmission of data is facilitated.
Before step S103, the method further includes: after receiving the second message, the netty program module judges whether the netty program module is connected with the first channel of the rabbitmq queue; if the first channel is connected, sending the second message packet to a rabbitmq queue through the first channel; if the first channel is disconnected, the first channel is reconnected through a heartbeat program, and after reconnection is completed, the second message packet is sent to the rabbitmq queue through the first channel.
Specifically, after the netty program module receives the second message, it needs to be determined whether the netty program module is connected to the first channel of the rabbitmq queue, and if the netty program module is not connected, the heartbeat program is started to reconnect; and when the connection is successful or is already connected, sending the second message packet to the rabbitmq queue through the first channel.
Wherein, reconnect the first passageway through the heartbeat procedure, specifically include: requesting a first channel through a domain name, a port, a designated account and a password of a rabbitmq queue; performing a connection request through a standard protocol, and establishing connection between the netty program module and the first channel; and returning a prompt that the connection between the netty program module and the first channel is successful.
Specifically, the establishment of the first channel is similar to the establishment of the second channel in that the request is made through a rabbitmq queue and is realized through a standard protocol, but the first channel is used for establishing the connection between the netty program module and the first channel, and a prompt is returned after the establishment is successful.
In one embodiment, the usage scenario of the method may be: when the client is at the applet client, the applet client enters a micro chat interface, a designated business consultant is selected to enter the chat interface, real-time chat messages can be sent with the business consultant, the business consultant opens a micro chat list at the APP client, the content of the messages sent by the client can be seen, and the reply is carried out in time.
As shown in fig. 2, there is provided a real-time message processing system including: netty program module 10,code encapsulation module 20,rabbitmq queue 30 andnodejs program module 40, wherein:
the netty program module 10 is configured to receive first information pushed by the netty program module 10 through UDP connection, analyze and present the first information;
acode encapsulation module 20, configured to receive a second message input by a user, determine a target receiving end according to the first tag, and encapsulate the second message and the target receiving end to obtain a second message packet;
the netty program module 10 is further configured to send the second message packet to therabbitmq queue 30 through the first channel when the second message packet is sent to the netty program module 10;
therabbitmq queue 30 is configured to parse the second message packet, obtain a target receiving end, and send the second message packet to thenodejs program module 40 through the second channel;
and thenodejs program module 40 is configured to parse the second message packet, obtain the second message, and send the second message to the target receiving end through the TCP connection.
In this embodiment, the system includes an APP micro chat service based on the netty program module 10, acode encapsulation module 20 for implementing encapsulation of a message, an applet micro chat service based on thenodejs program module 40, and arabbitmq queue 30 for implementing connection between the netty program module 10 and thenodejs program module 40, so that message intercommunication between the applet client and the APP client can be implemented, and the message can be processed in time.
In one embodiment, further comprising: and the interface module is used for realizing basic functional support during the initialization of the client interface, such as reading a current chat list, reading history messages or marking unread messages and the like.
In one embodiment, thecode encapsulation module 20 is specifically configured to: acquiring a local configuration file, and acquiring a server domain name and port information according to the local configuration file; and calling an encapsulation code module, and encapsulating the second message and the target receiving end according to the server domain name and the port information to obtain a second message packet.
In one embodiment, the netty program module 10 is further adapted to: after the netty program module 10 receives the second message packet, judging whether the netty program module 10 is connected with the first channel of therabbitmq queue 30; if the first channel is connected, sending the second message packet to therabbitmq queue 30 through the first channel; if the first channel is disconnected, the first channel is reconnected through a heartbeat program, and after the reconnection is completed, the second message packet is sent to therabbitmq queue 30 through the first channel.
In one embodiment, a device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 3. The device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the device is configured to provide computing and control capabilities. The memory of the device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the device is used for storing configuration templates and also can be used for storing target webpage data. The network interface of the device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a real-time message processing method.
Those skilled in the art will appreciate that the configuration shown in fig. 3 is a block diagram of only a portion of the configuration associated with the present application and does not constitute a limitation on the devices to which the present application may be applied, and that a particular device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In an embodiment, a storage medium may also be provided, the storage medium storing a computer program comprising program instructions which, when executed by a computer, which may be part of one of the above-mentioned real-time message processing systems, cause the computer to perform the method according to the preceding embodiment.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
It will be apparent to those skilled in the art that the modules or steps of the invention described above may be implemented in a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and optionally they may be implemented in program code executable by a computing device, such that they may be stored on a computer storage medium (ROM/RAM, magnetic disks, optical disks) and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The foregoing is a more detailed description of the present invention that is presented in conjunction with specific embodiments, and the practice of the invention is not to be considered limited to those descriptions. For those skilled in the art to which the invention pertains, several simple deductions or substitutions can be made without departing from the spirit of the invention, and all shall be considered as belonging to the protection scope of the invention.