Message push method, device, medium and electronic device
By saving and identifying messages in the storage database and pushing them when the web client reconnects, the problem of messages not being pushed after the user logs out is solved and the reliability and durability of message push are improved.
Patent Information
- Application Number
- CN202211156420.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-22
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-09-22
AI Technical Summary
In the question and answer service, after the user logs out, the data connection between the web client and the business server is disconnected, causing the business server to be unable to push messages to the web client. Even if the user logs in again, he cannot obtain previously unpushed messages, which affects message push. reliability.
By configuring the storage database, save the message that needs to be pushed and set the push identifier for it to determine whether the message has been pushed to the web side. If not, send the corresponding message in the newly established data connection to ensure that the message is reconnected to the web side. was pushed.
It improves the reliability of the business server pushing messages to the web end, avoids the situation where the message cannot be pushed to the web end, and enhances the persistence and reliability of the message.
Smart Images

Figure CN115514731B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer network technology, and in particular to a message push method, device, medium and electronic device. Background Art
[0002] In the question-and-answer service, users can send questions to the business server through the web terminal in the logged-in browser, and the business server will send the corresponding answer information to the web terminal. In addition, the business server can also actively push corresponding business messages to the web terminal, such as advertising links, new product reminders, etc.
[0003] However, after the user logs out of the web terminal, the data connection between the web terminal and the business server will be disconnected. At this time, the business server cannot push messages to the web terminal. Even if the user logs in to the web terminal again, he will not receive any messages from the business server.
[0004] Therefore, there is an urgent need for a technical solution that can improve the reliability of message push from a business server to a web terminal. Summary of the invention
[0005] In view of this, the present application provides a message push method, device, medium and electronic device for improving the reliability of a business server pushing messages to a web terminal, as follows:
[0006] A message push method, applied to a business server, comprising:
[0007] Obtaining a first message from a Redis-based message database; the first message is saved by a message server to a storage database and published to the message database, the storage database stores at least one push message, the push message in the storage database has a first push identifier or a second push identifier, the first push identifier indicates that the push message to which it belongs has been pushed to a corresponding web end, and the second push identifier indicates that the push message to which it belongs has not been pushed to a corresponding web end;
[0008] Searching for a target connection corresponding to the first message in a first websocket-based data connection currently established by the business server;
[0009] When a target connection corresponding to the first message is found in the first data connection, sending the first message to a first web terminal corresponding to the target connection through the target connection and setting the first push identifier for the first message in the storage database;
[0010] If no target connection corresponding to the first message is found in the first data connection, monitoring whether a new second data connection based on websocket is created on the business server;
[0011] When a new websocket-based second data connection is created on the business server, determining whether there is a second message with the second push identifier corresponding to the second data connection in the storage database;
[0012] In a case where the second message corresponding to the second data connection exists in the storage database, the second message is sent to a second web terminal corresponding to the second data connection through the second data connection.
[0013] In the above method, preferably, when there are multiple second messages, each of the second messages has a message publishing time;
[0014] The sending the second message to a second web terminal corresponding to the second data connection through the second data connection includes:
[0015] Each of the second messages is sent to the second web end corresponding to the second data connection through the second data connection in sequence according to the chronological order of the message publishing time.
[0016] In the above method, preferably, the first message is saved to the storage database and published to the message database by the message server after being generated;
[0017] Alternatively, the first message is saved to the storage database and published to the message database by the message server after being generated and when a preset push condition is met.
[0018] In the above method, preferably, the push condition includes: the first message corresponds to a preset push time, and the current time on the message server is consistent with the push time.
[0019] In the above method, preferably, the business server corresponds to the target subscription channel in the message database, and the target subscription channel matches the business service type provided by the business server for the web terminal, so that the message database sends its corresponding push message to all business servers corresponding to the target subscription channel through the target subscription channel.
[0020] The above method preferably further comprises:
[0021] receiving an access request sent by the first web terminal, wherein the access request includes user information stored in the first web terminal; the user information is sent to the first web terminal by the business server after performing login identity authentication on a login user of the first web terminal and the login identity authentication passes;
[0022] Performing access identity authentication on the logged-in user of the first web terminal according to the user information in the access request to obtain an access authentication result;
[0023] When the access authentication result indicates that the access identity authentication of the logged-in user of the first web terminal is passed, access data corresponding to the access request is sent to the first web terminal.
[0024] A message push device, applied to a business server, comprising:
[0025] A message obtaining unit, configured to obtain a first message from a Redis-based message database; the first message is saved by a message server to a storage database and published to the message database, the storage database stores at least one push message, the push message in the storage database has a first push identifier or a second push identifier, the first push identifier indicates that the push message to which it belongs has been pushed to a corresponding web terminal, and the second push identifier indicates that the push message to which it belongs has not been pushed to a corresponding web terminal;
[0026] a connection search unit, configured to search for a target connection corresponding to the first message in a first websocket-based data connection currently established by the business server; trigger a message push unit when a target connection corresponding to the first message is found in the first data connection; and trigger a connection monitoring unit when a target connection corresponding to the first message is not found in the first data connection;
[0027] The message pushing unit is used to send the first message to a first web terminal corresponding to the target connection through the target connection and set the first push identifier for the first message in the storage database;
[0028] The connection monitoring unit is used to monitor whether a new second data connection based on websocket is created on the business server; when a new second data connection based on websocket is created on the business server, trigger the message matching unit;
[0029] The message matching unit is used to determine whether there is a second message with the second push identifier corresponding to the second data connection in the storage database; when the second message corresponding to the second data connection exists in the storage database, the message push unit is triggered to send the second message to the second web terminal corresponding to the second data connection through the second data connection.
[0030] In the above device, preferably, when there are multiple second messages, each of the second messages has a message release time;
[0031] The sending the second message to a second web terminal corresponding to the second data connection through the second data connection includes:
[0032] Each of the second messages is sent to the second web end corresponding to the second data connection through the second data connection in sequence according to the chronological order of the message publishing time.
[0033] A computer-readable medium having a computer program stored thereon, wherein the computer program implements any of the methods described above when executed by a processor.
[0034] An electronic device, comprising:
[0035] one or more processors;
[0036] a storage device having one or more computer programs stored thereon;
[0037] When the one or more computer programs are executed by the one or more processors, the one or more processors are enabled to implement any of the methods described above.
[0038] It can be seen from the above technical scheme that in a message push method, device, medium and electronic device disclosed in the present application, a storage database is configured to store push messages that the message server needs to push, and a push identifier is configured for the push messages stored in the storage database to indicate whether the push messages to which they belong have been pushed to the web end. Based on this, even if the business server cannot push the first message currently obtained to the corresponding web end, the second message can be sent to the web end corresponding to the newly established data connection when the newly established data connection corresponds to the second message that has not been pushed in the storage database. It can be seen that in the present application, when the data connection between the web end and the business server is disconnected, the message is not pushed directly, but the message is saved in the database, and the corresponding message is read from the storage database and pushed to the web end after the corresponding web end re-establishes the data connection with the business server, thereby avoiding the situation where the message cannot be pushed to the web end, and then improving the reliability of the business server pushing messages to the web end. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0040] Figure 1 A flowchart of a message push method provided in Example 1 of the present application;
[0041] Figure 2 A partial flow chart of a message push method provided in Example 1 of the present application;
[0042] Figure 3 A schematic diagram of the structure of a message push device provided in Example 2 of the present application;
[0043] Figure 4 A schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present application;
[0044] Figure 5 This application is applicable to the overall architecture diagram of bank intelligent customer service to implement message push;
[0045] Figure 6 This application is applicable to the architecture diagram of the bank's intelligent customer service publishing subscription messages through Redis;
[0046] Figure 7 This is an example diagram of a model for implementing scheduled message push for bank intelligent customer service that is applicable to this application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] refer to Figure 1 , is a flow chart of a message push method provided in the first embodiment of the present application, which can be applied to a business server that can provide question-and-answer services, such as intelligent customer service. The technical solution in this embodiment is mainly used to improve the reliability of message push.
[0049] Specifically, the method in this embodiment may include the following steps:
[0050] Step 101: Obtain a first message from a Redis-based message database.
[0051] The first message is saved by the message server to the storage database and published to the message database. For example, the message server is a Redis-based server, and the message database is a Redis-based database. Based on this, at least one push message is stored in the storage database, and the push message in the storage database has a first push identifier or a second push identifier, the first push identifier indicates that the push message to which it belongs has been pushed to the corresponding web end, and the second push identifier indicates that the push message to which it belongs has not been pushed to the corresponding web end.
[0052] It should be noted that, when the first message is saved in the message database, the push identifier of the first message is the second push identifier.
[0053] In a specific implementation, the storage database may be an Oracle storage database to achieve persistent storage of push messages.
[0054] In addition, the message database has multiple subscription channels, each of which corresponds to a different business service type, such as a question-and-answer business service type, a shopping business service type, a financial business service type, etc. Based on this, the business server that provides question-and-answer services for the web side in this embodiment can be configured as a server cluster, with one or more business servers in the cluster, and a business server in the cluster provides question-and-answer services for the web side, and each business server in the cluster corresponds to a target subscription channel in the message database, and the target subscription channel matches the business service type provided by the business server for the web side, such as the question-and-answer service type. Based on this, the message database sends the push message corresponding to the channel (the push message that matches the business service type corresponding to the target subscription channel) to all business servers corresponding to the target subscription channel through the target subscription channel, thereby, the push message corresponding to the question-and-answer service type can be sent to each business server that provides question-and-answer services.
[0055] Step 102: In the first websocket-based data connection currently established by the business server, search for a target connection corresponding to the first message. If the target connection corresponding to the first message is found in the first data connection, execute step 103; if the target connection corresponding to the first message is not found in the first data connection, execute step 104.
[0056] Among them, when the user logs in to the web terminal, one of the business servers in the server cluster where the business server is located is selected to establish a websocket-based data connection with the web terminal, and when the user logs out of the web terminal, the websocket-based data connection between the web terminal and the business server is disconnected. The first data connection in this embodiment refers to the websocket-based data connection established on the current business server and the web terminal that is still in a connected state.
[0057] Based on this, after obtaining the first message, the business server can search whether there is a first data connection corresponding to the first message in its first data connection, for example, to find out whether there is a first data connection that matches the message identifier in the first message. The message identifier here can be a user identifier (logged-in user). Based on this, if there is a web-side logged-in user corresponding to the first data connection that is consistent with the user identifier in the first message, then it can be determined that the first data connection is the target connection corresponding to the first message.
[0058] Step 103: Send the first message to the first web terminal corresponding to the target connection through the target connection and set a first push identifier for the first message in the storage database.
[0059] Among them, after the business server finds the target connection corresponding to the first message, it sends the first message to the first web terminal of the opposite end through the target connection, thereby realizing the push of the first message. In addition, when the business server completes the push of the first message, the push identifier of the first message in the storage database is set to the first push identifier to indicate that the first message in the storage database has been pushed.
[0060] Step 104: monitor whether a new second data connection based on websocket is created on the business server. If a new second data connection based on websocket is created on the business server, execute step 105.
[0061] Among them, when the business server fails to find the first data connection corresponding to the first message, it indicates that the user on the web end to which the first message needs to be pushed has logged out, that is, the data connection based on websocket has been disconnected. At this time, in order to realize the message push, the business server can monitor whether there is a new second data connection, for example, whether there is a user logging in to the web end and then establishing a new data connection based on websocket, and then execute step 105 if there is a new second data connection.
[0062] Step 105: Determine whether there is a second message with a second push identifier corresponding to the second data connection in the storage database; if there is a second message corresponding to the second data connection in the storage database, execute step 106.
[0063] That is to say, after detecting that a new second data connection has been created, the business server can check whether the second message that has not been pushed in the storage database matches the new second data connection, for example, check whether the user logged in to the web terminal corresponding to the new second data connection matches the user identifier of the second message that has not been pushed. If they match, it means that the user corresponding to the user identifier in the second message has logged in to the web terminal again to re-establish the websocket-based data connection between the business server and the web terminal. At this time, step 106 can be executed.
[0064] Step 106: Send the second message to the second web terminal corresponding to the second data connection through the second data connection.
[0065] It should be noted that the second message may be the first message with a second push identifier. Therefore, in this embodiment, the service server may not push the message when the user logs out of the web terminal, but push the message after the user logs back in to the web terminal.
[0066] It can be seen from the above technical scheme that in a message push method provided in the first embodiment of the present application, a storage database is configured to store push messages that the message server needs to push, and a push identifier is configured for the push messages stored in the storage database to indicate whether the push messages to which they belong have been pushed to the web end. Based on this, even if the business server cannot push the first message currently obtained to the corresponding web end, the second message can be sent to the web end corresponding to the newly established data connection when the newly established data connection corresponds to the second message that has not been pushed in the storage database. It can be seen that in the present application, when the data connection between the web end and the business server is disconnected, the message is not pushed directly, but the message is saved in the database, and the corresponding message is read from the storage database and pushed to the web end after the corresponding web end re-establishes the data connection with the business server, thereby avoiding the situation where the message cannot be pushed to the web end, and then improving the reliability of the business server pushing messages to the web end.
[0067] In one implementation, the push messages in the storage database each have a message publishing time, and the message publishing time is the time when the push message to which it belongs is published by the message server to the message database, thereby representing the order in which the push messages are published, that is, the order in which they need to be pushed. Based on this, when there are multiple second messages with a second push identifier corresponding to the second data connection in the storage data, in step 106 of this embodiment, each second message can be sent to the second web end corresponding to the second data connection through the second data connection in sequence according to the order of the message publishing time, that is, the second messages are sent to the second web end in sequence according to the order in which each second message is published to the message database.
[0068] In one implementation, the first message is generated by the message server according to the message content in the message customization operation when the message server receives the message customization operation performed by the business party on the message customization interface. Based on this, the first message can be saved to the storage database and published to the message database by the message server after it is generated, or the first message can be saved to the storage database and published to the message database by the message server after it is generated and the preset push conditions are met.
[0069] For example, the push condition may be: the first message corresponds to a preset push time, and the current time on the message server is consistent with the push time. For example, the first message is set to a push time of 10:00 on August 2. Based on this, when the current time on the message server reaches 10:00 on August 2, the first message is saved to the storage database and published to the message database, and then the business server can obtain the first message through the target subscription channel and push the first message to the corresponding first web terminal. It can be seen that based on the setting of the push condition in this embodiment, the scheduled push of messages can be realized.
[0070] It should be noted that these first messages can be stored in a storage database of MySQL.
[0071] For another example, the push condition may be: the message server receives push idle information sent by the storage database, and the push idle information indicates that all push messages in the storage database have the first push identifier. In other words, all push messages in the storage database have been pushed to the corresponding web end, and there are no messages to be pushed. At this time, the storage database sends push idle information to the message server to indicate that the message server can save the push messages generated but not published on it to the storage database and publish them to the message database, so that the business server can continue to obtain push messages from the message database and push them to the corresponding web end. It can be seen that the setting based on push conditions in this application can improve resource utilization and avoid excessive idleness of business servers.
[0072] In one implementation, the business server in this embodiment corresponds to a target subscription channel in a message database, and the target subscription channel matches the business service type provided by the business server for the web end, so that the message database sends its corresponding push message to all business servers corresponding to the target subscription channel through the target subscription channel. As a result, the business server that has established a websocket-based data connection with the web end can definitely obtain the push message from the message database, and then the business server can push the push message obtained from the message database to the web end, avoiding the situation where the business server that obtains the push message is inconsistent with the business server with which the data connection is established, resulting in the omission of the message.
[0073] In one implementation, the method in this embodiment may further include the following steps: Figure 2 As shown in:
[0074] Step 107: Receive an access request sent by the first web terminal.
[0075] The access request includes user information stored in the first web terminal. The user information is sent to the first web terminal by the business server after the login identity authentication is performed on the login user of the first web terminal and the login identity authentication is passed.
[0076] Specifically, the user information may include a user name and password of a user logged in to the first web terminal and identification information of a user who has passed the login identity authentication, or the user information may include other information content representing the identity authentication of the user logged in to the first web terminal.
[0077] For example, the user information may be cookie information stored in the first web terminal.
[0078] Step 108: Perform access identity authentication on the login user of the first web terminal according to the user information in the access request to obtain an access authentication result. If the access authentication result indicates that the login user of the first web terminal has passed the access identity authentication, execute step 109.
[0079] For example, in this embodiment, the cookie information in the first web terminal carried in the access request is used to perform access identity authentication on the logged-in user of the first web terminal. The obtained access authentication result represents whether the user has legal access rights. If the user has legal access rights, then step 109 is executed.
[0080] Step 109: Send access data corresponding to the access request to the first web terminal.
[0081] The business server may obtain corresponding access data according to the access identifier in the access request, and then send the access data to the first web end through the first data connection corresponding to the first web end.
[0082] For example, after a user on the first web terminal logs in, the first web terminal establishes a first data connection with the business server, and the business server sends the user information that has passed the login authentication to the first web terminal, which is saved by the first web terminal in the form of cookie information. Based on this, after the business server pushes a message about a new link to the first web terminal, the user on the first web terminal clicks on the new link to generate an access request for a new product. The access request contains the user information of the logged-in user on the first web terminal, and the access request is sent to the business server. The business server re-authenticates the logged-in user on the first web terminal through the cookie information in the access request. If the authentication is successful, the business server sends the product page link of the new product to the first web terminal.
[0083] refer to Figure 3, is a structural diagram of a message push device provided in the second embodiment of the present application, which can be applied to a business server that can provide question-and-answer services for a web terminal. The technical solution in this embodiment is mainly used to improve the reliability of message push.
[0084] Specifically, the device in this embodiment may include the following units:
[0085] The message obtaining unit 301 is used to obtain a first message from a Redis-based message database; the first message is saved by a message server to a storage database and published to the message database, the storage database stores at least one push message, the push message in the storage database has a first push identifier or a second push identifier, the first push identifier indicates that the push message to which it belongs has been pushed to a corresponding web end, and the second push identifier indicates that the push message to which it belongs has not been pushed to a corresponding web end;
[0086] The connection search unit 302 is used to search for a target connection corresponding to the first message in the first websocket-based data connection currently established by the business server; if the target connection corresponding to the first message is found in the first data connection, the message push unit 303 is triggered; if the target connection corresponding to the first message is not found in the first data connection, the connection monitoring unit 304 is triggered;
[0087] The message pushing unit 303 is used to send the first message to the first web terminal corresponding to the target connection through the target connection and set the first push identifier for the first message in the storage database;
[0088] The connection monitoring unit 304 is used to monitor whether a new second data connection based on websocket is created on the business server; when a new second data connection based on websocket is created on the business server, the message matching unit 305 is triggered;
[0089] The message matching unit 305 is used to determine whether there is a second message with the second push identifier corresponding to the second data connection in the storage database; when the second message corresponding to the second data connection exists in the storage database, the message push unit 303 is triggered to send the second message to the second web terminal corresponding to the second data connection through the second data connection.
[0090] It can be seen from the above technical scheme that in a message push device provided in the second embodiment of the present application, a storage database is configured to store push messages that the message server needs to push, and a push identifier is configured for the push messages stored in the storage database to indicate whether the push messages to which they belong have been pushed to the web end. Based on this, even if the business server cannot push the first message currently obtained to the corresponding web end, the second message can be sent to the web end corresponding to the newly established data connection when the newly established data connection corresponds to the second message that has not been pushed in the storage database. It can be seen that in the present application, when the data connection between the web end and the business server is disconnected, the message is not pushed directly, but the message is saved in the database, and the corresponding message is read from the storage database and pushed to the web end after the corresponding web end re-establishes the data connection with the business server, thereby avoiding the situation where the message cannot be pushed to the web end, and then improving the reliability of the business server pushing messages to the web end.
[0091] In one implementation, when there are multiple second messages, each of the second messages has a message publishing time;
[0092] Among them, when the message push unit 303 sends the second message to the second web end corresponding to the second data connection through the second data connection, it is specifically used to: send each second message to the second web end corresponding to the second data connection through the second data connection in the order of the message release time.
[0093] It should be noted that the specific implementation of each unit in this embodiment can refer to the corresponding content in the previous text and will not be described in detail here.
[0094] refer to Figure 4 , is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present application. The electronic device is a business server that provides question-and-answer services. Specifically, the business server may include the following structure:
[0095] One or more processors 401;
[0096] a storage device 402 on which one or more computer programs are stored;
[0097] When the one or more computer programs are executed by the one or more processors, the one or more processors implement the message pushing method as described in the above embodiments.
[0098] An embodiment of the present application further provides a computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the message push method as described in the above embodiment.
[0099] An embodiment of the present application further provides a processor, which is used to run a program, wherein the message push method described in the above method embodiments is implemented when the program is run.
[0100] The embodiment of the present application also provides a computer program product, which, when executed on a data processing device, enables the data processing device to implement the message push method described in the above method embodiments.
[0101] Taking the business server as the server of the bank's intelligent customer service as an example, in order to improve the reliability of the business server pushing messages to the web end, this application proposes a websocket-based question-and-answer customer service directional and timed push solution, refer to Figure 5 The overall architecture diagram shown in the figure is as follows:
[0102] The cluster declaration web end (web client) of the OCP (OpenShift Container Platform) cloud server (business server) can be used to establish a websocket duplex communication interface, and adopts a user authentication mechanism based on browser cookies. After the user identity authentication is passed, the cloud cluster saves the corresponding user identity information and session information in the corresponding server, and subscribes (Subscribe) to the corresponding channel of the Redis (Remote Dictionary Server) cluster. After receiving the message published (Publish) by the specified Redis channel, it picks up the corresponding websocket session and pushes the message to the specified user. In order to adapt to the multi-cluster service on the cloud, Nginx message middleware can be used to realize the forwarding of user messages. In terms of business, a question-and-answer customer service message center is built for use by various business demand parties. The message center provides a variety of business scenarios such as online message push, offline message push, and scheduled message sending. The corresponding message is published through the Redis channel to realize the reliable push of business party messages. For example, each user logs in to the corresponding web client A, B, and C respectively. After the business party customizes the message in the message customization interface, it notifies the message center (message server) of the message. After that, the message server publishes these push messages to the message database (Redis database cluster) and saves them to the corresponding storage database (MySQL database and Oracle database). As a result, each business server Cluster in the cloud server cluster obtains the push messages in the Redis database through the subscribed channels, and the business server then uses the Nginx middleware to push the push messages to the corresponding web client.
[0103] The following describes the solutions for user identity security authentication, message leakage problem resolution, offline message push, scheduled message push, and online reminders:
[0104] (1) User identity security authentication:
[0105] In order to improve the security of websocket message push, an identity authentication mechanism based on web browser cookies is proposed. After the user logs in securely with the username and password, he carries the specified cookie request to establish websocket communication. This application provides two interceptors to verify the user cookie, one identity interceptor is used to release the user login information after security authentication, and the other business interceptor is used to save the user identity and related business information to the corresponding session.
[0106] (2) Solution to the problem of message leakage:
[0107] This application adopts the multi-cluster deployment method on the OCP cloud and uses Nginx to forward user requests, so the user websocket session is saved in a random cloud cluster. This application adopts the Redis publish / subscribe (Sub / Pub) message mode to publish messages: each cluster subscribes to the Redis specified channel, and the message center sends messages to the Redis specified channel to achieve full coverage of multi-cluster message push. For the corresponding message delivery method, please refer to Figure 6 As shown in the architecture diagram of Redis publish-subscribe messaging.
[0108] For example, messages A, B, C, D in scenarios A, B, C, D are published to the Redis database cluster, and the corresponding business server clusters Sever1 and Sever2 obtain the corresponding messages A, B, C, D by subscribing to the specified channel of Redis. Finally, users A, B, C, D obtain the corresponding messages pushed by Sever after cookie authentication, so there will be no problem of message leakage.
[0109] (3) Offline message push:
[0110] Web users are not always online, and the websocket message push of the Q&A customer service needs to be based on the user being online, so the message push is often blocked. To solve the above problem, this application designs a mode to ensure the reliability of message push: the message that the Q&A customer service needs to push to the user when the user is offline is not pushed directly, but saved in the Oracle database through message persistence. When the user logs in next time, the corresponding offline message table (push message with the second push identifier) is scanned and pushed to the web user in the order of the release time. The corresponding offline message table structure is shown in Table 1.
[0111] Table 1 Offline message table
[0112] MESSAGEID USERID CONTENT CREATETIME PUBLISHTIME PUSHID MessageId UserId Message content Push time Release time Second push identifier
[0113] (4) Scheduled message push:
[0114] This application designs a mode for scheduled message push for Q&A customer service, which is used to meet business scenarios such as hourly message push and scheduled reminders. The business party configures hourly push and scheduled push messages in the message center based on Cronb expressions. The message center generates scheduled jobs based on Java timers, and publishes the formulated messages to the specified Redis channel according to the time nodes in the time sequence. When the cloud cluster receives the message published by Redis, it first determines the current online status of the user. If the user is online, the message is pushed directly; if the user is offline, the scheduled message is converted to an offline message, and the push is completed when the user logs in. The design pattern of scheduled message push is as follows: Figure 7 As shown. For example, when the timer reaches the timer, messages A and B in scenarios A and B are published to the Redis database cluster. The corresponding business server cluster Sever obtains the corresponding messages A and B by subscribing to the specified channel of Redis, and determines whether the socket connection corresponding to messages A and B exists. If so, it is directly pushed to the web user. If not, it is converted to an offline message and saved in the Oracle database. For example, the web user corresponding to message A is online. At this time, message A is pushed to the web to provide it to user A. For another example, the web user corresponding to message B is not online. At this time, message B is converted to an offline message and saved in the Oracle database. When the user logs in to the web again, that is, when he is back online, the business server that establishes the websocket connection pushes message B in the Oracle database to the web to provide it to user B.
[0115] (5) Online reminder:
[0116] In terms of web-side message reminders, this application can achieve two effects based on CSS3 (Cascading Style Sheets Level 3). One is that when the Q&A customer service receives a push message, the avatar will shake according to the preset CSS3 animation to remind the user that the push message has been received. The other is to implement the "+1" function for unread messages based on JaveScript, and bind a click event to the customer service avatar. When the user clicks the avatar to read the push message, the number of unread messages will be reset.
[0117] In summary, this application proposes a websocket-based Web-based question and answer customer service message directional and scheduled push solution, which fills the gap in browser Web-based question and answer customer service message push, and implements the functions of offline message push and scheduled message push in the solution, focusing on solving the reliability problem of message push after Web users are offline, enriching the Web-based question and answer customer service message interaction mode, and improving the channels for new reminders, alarm notifications, message releases and other functions of the message center.
[0118] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0119] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0120] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0121] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A message push method, characterized in that: Applied to a business server, the business server is configured as a server cluster, the server cluster includes one or more business servers, services are provided by a business server in the server cluster, each business server in the server cluster corresponds to a target subscription channel in a message database, the method includes: Obtaining a first message from a Redis-based message database; the first message is saved by a message server to a storage database and published to the message database, the storage database storing at least one push message, the push message in the storage database having a first push identifier or a second push identifier, the first push identifier indicating that the push message to which it belongs has been pushed to the corresponding web end, and the second push identifier indicating that the push message to which it belongs has not been pushed to the corresponding web end; the message database having multiple subscription channels, each subscription channel corresponding to a different business service type; Searching for a target connection corresponding to the first message in a first websocket-based data connection currently established by the business server; When a target connection corresponding to the first message is found in the first data connection, sending the first message to a first web terminal corresponding to the target connection through the target connection and setting the first push identifier for the first message in the storage database; If no target connection corresponding to the first message is found in the first data connection, monitoring whether a new websocket-based second data connection is created on the business server; When a new websocket-based second data connection is established on the business server, determining whether a second message having the second push identifier corresponds to the second data connection in the storage database; If the second message corresponding to the second data connection exists in the storage database, sending the second message to a second web terminal corresponding to the second data connection through the second data connection; The business server corresponds to a target subscription channel in the message database, and the target subscription channel matches a business service type provided by the business server for the web terminal, so that the message database sends a push message matching the business service type corresponding to the target subscription channel to all business servers corresponding to the target subscription channel through the target subscription channel; The first message is saved to the storage database and published to the message database by the message server after being generated; or, the first message is saved to the storage database and published to the message database by the message server after being generated and when a preset push condition is met, and the preset push condition is: the message server receives push idle information sent by the storage database, and the push idle information indicates that all push messages in the storage database have a first push identifier.
2. The method according to claim 1, characterized in that When there are multiple second messages, each second message has a message publishing time; The sending, through the second data connection, the second message to the second web terminal corresponding to the second data connection includes: Each second message is sent to the second web end corresponding to the second data connection through the second data connection in sequence according to the order of the message publishing time.
3. The method according to claim 1, characterized in that The push condition includes: the first message corresponds to a preset push time, and the current time on the message server is consistent with the push time.
4. The method according to claim 1 or 2, characterized in that Also includes: receiving an access request sent by the first web terminal, wherein the access request includes user information stored in the first web terminal; The user information is sent to the first web terminal by the business server after the login identity authentication of the login user of the first web terminal is passed; Performing access identity authentication on the logged-in user of the first web terminal according to the user information in the access request to obtain an access authentication result; When the access authentication result indicates that the access identity authentication of the logged-in user of the first web terminal is passed, access data corresponding to the access request is sent to the first web terminal.
5. A message push device, characterized in that: Applied to a business server, the business server is configured as a server cluster, the server cluster includes one or more business servers, services are provided by a business server in the server cluster, each business server in the server cluster corresponds to a target subscription channel in a message database, the device includes: A message obtaining unit is configured to obtain a first message from a Redis-based message database; the first message is saved by a message server to a storage database and published to the message database, the storage database stores at least one push message, the push message in the storage database has a first push identifier or a second push identifier, the first push identifier indicates that the push message to which it belongs has been pushed to the corresponding web end, and the second push identifier indicates that the push message to which it belongs has not been pushed to the corresponding web end; the message database has multiple subscription channels, each subscription channel corresponding to a different business service type; a connection search unit, configured to search for a target connection corresponding to the first message in a first WebSocket-based data connection currently established by the business server; trigger the message push unit if a target connection corresponding to the first message is found in the first data connection; and trigger the connection monitoring unit if no target connection corresponding to the first message is found in the first data connection; The message pushing unit is configured to send the first message to a first web terminal corresponding to the target connection through the target connection and set the first push identifier for the first message in the storage database; The connection monitoring unit is configured to monitor whether a new websocket-based second data connection is established on the business server; and trigger the message matching unit when a new websocket-based second data connection is established on the business server; The message matching unit is configured to determine whether there is a second message with the second push identifier corresponding to the second data connection in the storage database; if the second message corresponding to the second data connection exists in the storage database, trigger the message push unit to send the second message to the second web terminal corresponding to the second data connection through the second data connection; The device further includes: the business server corresponds to a target subscription channel in the message database, and the target subscription channel matches a business service type provided by the business server for the web terminal, so that the message database sends a push message matching the business service type corresponding to the target subscription channel to all business servers corresponding to the target subscription channel through the target subscription channel; The first message is saved to the storage database and published to the message database by the message server after being generated; or, the first message is saved to the storage database and published to the message database by the message server after being generated and when a preset push condition is met, and the preset push condition is: the message server receives push idle information sent by the storage database, and the push idle information indicates that all push messages in the storage database have a first push identifier.
6. The device according to claim 5, characterized in that When there are multiple second messages, each second message has a message publishing time; The sending, through the second data connection, the second message to the second web terminal corresponding to the second data connection includes: Each second message is sent to the second web end corresponding to the second data connection through the second data connection in sequence according to the order of the message publishing time.
7. A computer-readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
8. An electronic device, characterized in that: include: one or more processors; a storage device having one or more computer programs stored thereon; When the one or more computer programs are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 4.
