Message pushing method, device and equipment, and storage medium

CN116996560BActive Publication Date: 2026-10-23QINGDAO HAIER TECH +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210445292.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-26
Publication Date
2026-10-23
Estimated Expiration
2042-04-26

AI Technical Summary

Benefits of technology

[0043]本领域技术人员能够理解的是,本发明的消息推送方法、装置、设备及存储介质,获取消息中间件分配的包含有待推送的目标终端的标识的当前消息,从预先存储在分布式缓存的终端标识与服务端地址的对应关系中,查找获取目标终端的标识对应的服务端地址,基于路由机制获得服务端地址对应的服务端,并从服务端中获取预先存储的目标终端的标识对应的通信协议,采用通信协议将当前消息推送到目标终端。上述方法中通过分布式缓存存储终端标识与服务端地址的对应关系,从而可以查找获取目标终端的标识对应的服务端地址,再基于路由机制获得服务端地址对应的服务端,获取目标终端的标识对应的通信协议,采用通信协议完成消息推送,从而每个消费端无需连接固定的终端,消息中间件可以将全部消息分配给一个预先指定的消费分组,该消费分组中的每个消费端只需消费部分消息,且消费的消息均可被准确推送到相应的目标终端,不会被丢弃,从而有效避免了对需要丢弃的消息进行传输和判断导致的时间浪费,提高了消息推送的效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116996560B_ABST
    Figure CN116996560B_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of computer, and particularly relates to a message pushing method and device, equipment and storage medium. The correspondence between the terminal identifier and the server address is stored through the distributed cache, so that the server address corresponding to the identifier of the target terminal can be found and obtained, and then the server corresponding to the server address is obtained based on the routing mechanism, the communication protocol corresponding to the identifier of the target terminal is obtained, the message pushing is completed by using the communication protocol, so that each consumer does not need to be connected to a fixed terminal, the message middleware can distribute all messages to a pre-specified consumer group, each consumer in the consumer group only needs to consume part of the messages, and the consumed messages can be accurately pushed to the corresponding target terminal and will not be discarded, so that the time waste caused by the transmission and judgment of the messages that need to be discarded is effectively avoided, and the efficiency of the message pushing is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, and specifically relates to a message push method, device, equipment, and storage medium. Background Technology

[0002] Push notifications refer to the process where, after the server performs the corresponding processing based on the business request sent by the target terminal, it needs to push a message to the target terminal to inform the user of the processing result.

[0003] Currently, a common message push method involves multiple servers sending multiple messages to a message middleware. The message middleware connects to multiple consumers, each connected to multiple terminals, and each consumer needs to retrieve and consume all messages from the message middleware. For a message retrieved by a consumer, the consumer needs to parse the message to determine the target terminal to which it is to be pushed. It then determines whether the target terminal is included among the multiple terminals connected to that consumer. If it is, the message is pushed to the corresponding target terminal; otherwise, the message is discarded.

[0004] However, in the above message push method, each consumer will consume a large number of messages that need to be discarded. Transmitting and judging the messages that need to be discarded will lead to a lot of wasted time. As the number of messages increases, it will cause network latency, resulting in messages not being pushed in a timely manner. Summary of the Invention

[0005] To address the aforementioned problems in the prior art, namely, to resolve the issues of significant time wastage during the transmission and judgment of messages that need to be discarded, and the resulting network latency as the number of messages increases, thus preventing timely message delivery, this invention provides a message delivery method, apparatus, device, and storage medium.

[0006] According to a first aspect of the present invention, the present invention provides a message push method applied to a consumer, the consumer being located in a pre-specified consumer group, the method comprising:

[0007] Get the current message allocated by the message middleware, wherein the current message contains the identifier of the target terminal to be pushed;

[0008] Based on the identifier of the target terminal, the server address corresponding to the identifier of the target terminal is retrieved from the mapping relationship between terminal identifiers and server addresses pre-stored in the distributed cache.

[0009] The server corresponding to the server address is obtained based on the routing mechanism, and the communication protocol corresponding to the identifier of the target terminal is obtained from the server in advance.

[0010] The current message is pushed to the target terminal using the aforementioned communication protocol.

[0011] In the preferred embodiment of the above message push method, obtaining the server corresponding to the server address based on the routing mechanism includes:

[0012] Obtain the pre-configured routing rules in the routing mechanism;

[0013] According to the routing rules, the server corresponding to the server address is obtained by reverse lookup; wherein, the pre-configured routing rules include the correspondence between the server and the server address.

[0014] In the preferred embodiment of the above message push method, the step of obtaining the communication protocol corresponding to the pre-stored identifier of the target terminal from the server includes:

[0015] Establish a local connection with the server.

[0016] The communication protocol corresponding to the identifier of the target terminal is obtained from the local cache of the server. The communication protocol corresponding to the identifier of the target terminal is stored in the local cache of the server when the target terminal first establishes a connection with the server.

[0017] According to a second aspect of the present invention, the present invention provides a message push method applied to a message middleware, the message middleware including multiple consumer groups, each consumer group corresponding to multiple consumer terminals; the method includes:

[0018] It can receive multiple messages from multiple servers; each message contains the identifier of the target terminal to be pushed to.

[0019] The multiple messages are assigned to pre-specified consumption groups, so that multiple consumers corresponding to the consumption groups consume the multiple messages according to the target terminal identifier in the multiple messages, and push the messages to the target terminal based on the target terminal's communication protocol when consuming the messages. The communication protocol is pre-stored on the server, and the server is the server address corresponding to the target terminal identifier. The correspondence between the terminal identifier and the server address is pre-stored in a distributed cache.

[0020] In the preferred embodiment of the above message push method, the step of assigning the multiple messages to pre-specified consumer groups, so that multiple consumers corresponding to the consumer groups can consume the multiple messages, includes:

[0021] The multiple messages are assigned to pre-specified consumer groups using a preset allocation strategy, so that each consumer in each consumer group can consume a portion of the multiple messages.

[0022] In the preferred embodiment of the above message push method, the method further includes:

[0023] For each message, determine whether the message has been successfully consumed;

[0024] If the message is not successfully consumed, it is stored in a delay queue so that the consumer can re-consume the message after a preset delay time.

[0025] In the preferred embodiment of the above message push method, determining whether the message has been successfully consumed for each message includes:

[0026] Receive the confirmation sequence number sent by the consumer; wherein, each message corresponds to a different confirmation sequence number;

[0027] For each message, determine whether the received acknowledgment sequence number contains the acknowledgment sequence number corresponding to the message;

[0028] If not included, it is determined that the message was not successfully consumed;

[0029] If the message is included, then the message consumption is considered successful.

[0030] According to a third aspect of the present invention, the present invention provides a message push device applied to a consumer, the consumer being located in a pre-specified consumer group, the device comprising:

[0031] The acquisition module is used to acquire the current message allocated by the message middleware, wherein the current message contains the identifier of the target terminal to be pushed;

[0032] The lookup module is used to search for and obtain the server address corresponding to the identifier of the target terminal from the mapping relationship between terminal identifiers and server addresses pre-stored in a distributed cache based on the identifier of the target terminal.

[0033] The acquisition module is further configured to obtain the server corresponding to the server address based on the routing mechanism, and obtain the communication protocol corresponding to the identifier of the target terminal that is pre-stored from the server.

[0034] The push module is used to push the current message to the target terminal using the communication protocol.

[0035] According to a fourth aspect of the present invention, the present invention provides a message push device applied to a message middleware, the message middleware including multiple consumer groups, each consumer group corresponding to multiple consumer terminals; the device includes:

[0036] The receiving module is used to receive multiple messages sent by multiple servers; each message contains the identifier of the target terminal to be pushed to.

[0037] The allocation module is used to allocate the multiple messages to pre-specified consumption groups, so that multiple consumers corresponding to the consumption groups consume the multiple messages according to the target terminal identifier in the multiple messages, and push the messages to the target terminal based on the target terminal's communication protocol when consuming the messages. The communication protocol is pre-stored on the server, and the server is the server address corresponding to the target terminal identifier. The correspondence between the terminal identifier and the server address is pre-stored in a distributed cache.

[0038] According to a fifth aspect of the present invention, an electronic device is provided, comprising: a processor, and a memory communicatively connected to the processor;

[0039] The memory stores computer-executed instructions;

[0040] The processor executes computer execution instructions stored in the memory to implement the message push method as described in either the first or second aspect of the embodiments of the present invention.

[0041] According to a sixth aspect of the present invention, the present invention provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the message push method as described in any one of the first or second aspects of the present invention.

[0042] According to a seventh aspect of the present invention, the present invention provides a computer program product, including a computer program that, when executed by a processor, implements the message push method as described in any one of the first or second aspects of the present invention.

[0043] Those skilled in the art will understand that the message push method, apparatus, device, and storage medium of the present invention obtain a current message containing the identifier of the target terminal to be pushed, allocated by a message middleware. It then searches for the server address corresponding to the target terminal's identifier from a pre-stored mapping between terminal identifiers and server addresses in a distributed cache. Based on a routing mechanism, it obtains the server corresponding to the server address and retrieves the pre-stored communication protocol corresponding to the target terminal's identifier from the server. Finally, it uses the communication protocol to push the current message to the target terminal. In this method, the distributed cache stores the mapping between terminal identifiers and server addresses, allowing for the search for the server address corresponding to the target terminal's identifier. The routing mechanism then obtains the server corresponding to the server address, retrieves the communication protocol corresponding to the target terminal's identifier, and uses the communication protocol to complete the message push. This eliminates the need for each consumer to connect to a fixed terminal. The message middleware can distribute all messages to a pre-specified consumer group. Each consumer in this group only needs to consume a portion of the messages, and all consumed messages are accurately pushed to the corresponding target terminal without being discarded. This effectively avoids the time wasted on transmitting and judging messages that need to be discarded, thus improving the efficiency of message push. Attached Figure Description

[0044] Preferred embodiments of the message push method, apparatus, device, and storage medium of the present invention will now be described with reference to the accompanying drawings. The drawings are as follows:

[0045] Figure 1 A schematic diagram illustrating an application scenario of a message push method provided by existing technology;

[0046] Figure 2 This is a schematic diagram illustrating an application scenario of the message push method provided in an embodiment of the present invention;

[0047] Figure 3 This is a flowchart illustrating a message push method provided in an embodiment of the present invention;

[0048] Figure 4 A flowchart illustrating another message push method provided in an embodiment of the present invention;

[0049] Figure 5 This is a schematic diagram of the structure of a message push device provided in an embodiment of the present invention;

[0050] Figure 6 This is a schematic diagram of the structure of another message push device provided in an embodiment of the present invention;

[0051] Figure 7 This is a schematic diagram of an electronic device provided in one embodiment of the present invention;

[0052] Figure 8This is a schematic diagram of an electronic device provided in another embodiment of the present invention. Detailed Implementation

[0053] First, those skilled in the art should understand that these embodiments are merely for explaining the technical principles of the present invention and are not intended to limit the scope of protection of the present invention. Those skilled in the art can make adjustments as needed to adapt to specific application scenarios.

[0054] Furthermore, it should be noted that, in the description of this invention, unless otherwise explicitly specified and limited, the terms "connected" and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0055] First, the terms used in this invention will be explained:

[0056] 1) A terminal refers to an electronic device with communication functions, such as a desktop computer, laptop computer, mobile phone, or smart home device. Users can establish a connection with the server through a web browser on the terminal. Specifically, in this embodiment of the invention, the terminal communicates with the server through the WebSocket full-duplex communication protocol.

[0057] 2) "Multiple" refers to two or more, and other quantifiers are similar. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following objects have an "or" relationship.

[0058] 3) “Correspondence” can refer to an association or binding relationship. A and B correspond to each other, which means that there is an association or binding relationship between A and B.

[0059] The following explains the application scenarios of existing technologies and embodiments of the present invention:

[0060] Figure 1 This is a schematic diagram illustrating an application scenario of a message push method provided by existing technology. For example... Figure 1As shown in the diagram, the system includes multiple servers 11, a message middleware 12, and multiple consumers 13 connected to each consumer 13. Each consumer 13 is connected to multiple terminals 14. The servers 11 send multiple messages to be pushed to the message middleware 12. Each consumer 13 retrieves all messages from the message middleware 12 and consumes them. For a message currently retrieved by a consumer 13, the consumer 13 needs to parse the message to obtain the target terminal to which the message is to be pushed, and determine whether the target terminal is included among the multiple terminals 14 connected to that consumer 13. If it is included, the message is pushed to the corresponding target terminal; otherwise, the message is discarded.

[0061] However, in the application scenarios of existing technologies, each consumer consumes a large number of messages that need to be discarded. Transmitting and judging the messages that need to be discarded will lead to a lot of wasted time. As the number of messages increases, it will cause network latency, resulting in messages not being pushed in a timely manner.

[0062] Figure 2 This is a schematic diagram illustrating an application scenario of the message push method provided in an embodiment of the present invention. For example... Figure 2 As shown in the diagram, the system includes multiple servers 21, multiple terminals 22, and a message middleware 23. The message middleware 23 includes multiple consumer groups, each corresponding to multiple consumers 24. Multiple servers 21 send multiple messages to be pushed to the message middleware 12. The message middleware 23 can allocate all messages to be pushed to a pre-specified consumer group. Each consumer 24 in this group only needs to obtain a portion of the messages from the message middleware 23 and consume them. For a message currently obtained by a consumer 24, the consumer 24 can look up the server address corresponding to the target terminal's identifier from the pre-stored mapping between terminal identifiers and server addresses in a distributed cache. Based on a routing mechanism, it obtains the server 21 corresponding to the server address, retrieves the pre-stored communication protocol corresponding to the target terminal's identifier from the server 21, and uses the communication protocol to push the current message to the target terminal.

[0063] The technical solution of the present invention and how the technical solution of the present invention solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of the present invention will now be described with reference to the accompanying drawings.

[0064] Figure 3 This is a flowchart illustrating a message push method provided in an embodiment of the present invention, as shown below. Figure 3As shown, the message push method provided in this embodiment is applied to the consumer end, which is located in a pre-specified consumer group. The method includes the following steps:

[0065] Step S301: Obtain the current message allocated by the message middleware, wherein the current message contains the identifier of the target terminal to be pushed.

[0066] Step S302: Based on the identifier of the target terminal, search for and obtain the server address corresponding to the identifier of the target terminal from the correspondence between terminal identifiers and server addresses pre-stored in the distributed cache.

[0067] Step S303: Obtain the server corresponding to the server address based on the routing mechanism, and obtain the communication protocol corresponding to the identifier of the target terminal that is pre-stored from the server.

[0068] Step S304: Push the current message to the target terminal using the communication protocol.

[0069] It should be noted that the execution entity of the message push method applied to the consumer end provided in this embodiment can be a message push device applied to the consumer end. In practical applications, this message push device applied to the consumer end can be implemented by a computer program, such as application software, or by a medium storing the relevant computer program, such as a USB flash drive or optical disc, or by a physical device that integrates or installs the relevant computer program, such as a chip.

[0070] In this embodiment, because existing technologies can only push messages to a few terminals connected to them, each consumer consumes a large number of messages that need to be discarded, causing network latency and resulting in messages not being pushed in a timely manner, in order to avoid wasting time during the message push process and improve the efficiency of message push, the server address can be obtained through distributed caching, and the corresponding server can be determined through a routing mechanism. The communication protocol corresponding to the target terminal in the server can then be obtained for message push.

[0071] Specifically, the message push device first obtains the current message allocated by the message middleware, which contains the identifier of the target terminal to be pushed. This current message is sent to the message middleware by one of multiple servers.

[0072] In one example, the current message contains a push notification request. The push notification device can obtain the identifier of the target terminal to which the message is to be pushed by parsing the current message. The identifier of the target terminal can be the target terminal ID or other suitable identifier, which is not limited in this embodiment.

[0073] Furthermore, it should be noted that the message middleware in this embodiment includes multiple consumer groups, each consumer group corresponding to multiple consumers. In this embodiment, the consumers are located within a pre-defined consumer group of the message middleware. This pre-defined consumer group can be pre-specified using its identifier.

[0074] After the message push device obtains the identifier of the target terminal, it can look up the server address corresponding to the identifier of the target terminal from the mapping relationship between terminal identifiers and server addresses that is pre-stored in the distributed cache.

[0075] The server address can be the IP address of the server.

[0076] In practical applications, after the terminal and server establish a connection for the first time, the mapping between the terminal identifier and the server address is stored in a distributed cache for subsequent lookups. This distributed cache can be a remote dictionary server (Redis) or other suitable distributed caches; this embodiment does not limit the specific type.

[0077] After the message push device obtains the server address corresponding to the identifier of the target terminal, it can obtain the server corresponding to the server address based on the routing mechanism, and obtain the communication protocol corresponding to the identifier of the target terminal from the server.

[0078] In one alternative implementation, in Figure 3 In step S303, obtaining the server corresponding to the server address based on the routing mechanism includes: obtaining the routing rules pre-configured in the routing mechanism; and reversely searching to obtain the server corresponding to the server address according to the routing rules; wherein the pre-configured routing rules include the correspondence between the server and the server address.

[0079] In this embodiment, the message push device can obtain pre-configured routing rules from the routing mechanism. This routing mechanism can be an IP routing mechanism, where pre-configured routing rules define the path taken by the server during data communication, i.e., the correspondence between the server and its IP address. Based on the obtained routing rules, the message push device can reverse-look up the server address (i.e., the server's IP address) to obtain the server corresponding to that address.

[0080] In yet another alternative implementation, in Figure 3In step S303, obtaining the communication protocol corresponding to the identifier of the target terminal from the server includes: establishing a local connection with the server; obtaining the communication protocol corresponding to the identifier of the target terminal from the local cache of the server; the communication protocol corresponding to the identifier of the target terminal is stored in the local cache of the server when the target terminal first establishes a connection with the server.

[0081] In this embodiment, after obtaining the server corresponding to the server address, the message push device can establish a local connection with the server and obtain the communication protocol corresponding to the pre-stored target terminal identifier from the server's local cache.

[0082] In practical applications, after the terminal and server establish a connection for the first time, the server saves the current connection, that is, it saves the identifier of the terminal and the communication protocol used in the current connection to the server's local cache. Specifically, the communication protocol can be the WebSocket communication protocol.

[0083] For example, when terminal A establishes an initial connection with server B, server B can save terminal A's identifier and the WebSocket communication protocol used by terminal A to establish the connection in its local cache. Similarly, when another terminal C establishes an initial connection with server B, server B can also save terminal C's identifier and the WebSocket communication protocol used by terminal C to establish the connection in its local cache. During a lookup, if the identifier of the target terminal obtained from the current message is the identifier of terminal A, the message push device can retrieve the pre-stored WebSocket communication protocol corresponding to terminal A from server B's local cache; that is, the communication protocol corresponding to the target terminal's identifier.

[0084] After the message push device obtains the communication protocol corresponding to the identifier of the target terminal, it can use the obtained communication protocol to push the current message to the corresponding target terminal.

[0085] Continuing with the previous example, after the message push device obtains the WebSocket communication protocol corresponding to terminal A, it can push the current message to terminal A through this communication protocol.

[0086] The message push method provided in this embodiment obtains a current message containing the identifier of the target terminal to be pushed, allocated by the message middleware. It then searches for the server address corresponding to the target terminal's identifier from a pre-stored mapping between terminal identifiers and server addresses in a distributed cache. Based on a routing mechanism, it obtains the server corresponding to the server address and retrieves the pre-stored communication protocol corresponding to the target terminal's identifier from the server. Finally, it uses the communication protocol to push the current message to the target terminal. In this method, the distributed cache stores the mapping between terminal identifiers and server addresses, allowing for the search for the server address corresponding to the target terminal's identifier. The routing mechanism then obtains the server address, the communication protocol, and the communication protocol to complete the message push. This eliminates the need for each consumer to connect to a fixed terminal. The message middleware can distribute all messages to a pre-specified consumer group. Each consumer in this group only needs to consume a portion of the messages, and all consumed messages are accurately pushed to the corresponding target terminal without being discarded. This effectively avoids the time wasted on transmitting and judging messages that need to be discarded, thus improving the efficiency of message push.

[0087] Figure 4 This is a flowchart illustrating another message push method provided in an embodiment of the present invention, as shown below. Figure 4 As shown, the message push method provided in this embodiment is applied to a message middleware, which includes multiple consumer groups, each consumer group corresponding to multiple consumers; the method includes the following steps:

[0088] Step S401: Receive multiple messages sent by multiple servers; each message contains the identifier of the target terminal to be pushed.

[0089] Step S402: Assign the multiple messages to pre-specified consumption groups, so that multiple consumer terminals corresponding to the consumption groups consume the multiple messages according to the target terminal identifier in the multiple messages, and push the messages to the target terminal based on the target terminal's communication protocol when consuming the messages. The communication protocol is pre-stored on the server, and the server is the server address corresponding to the target terminal identifier. The correspondence between the terminal identifier and the server address is pre-stored in a distributed cache.

[0090] It should be noted that the execution entity of the message push method for message middleware provided in this embodiment can be a message push device for message middleware. In practical applications, this message push device for message middleware can be implemented by a computer program, such as application software, or by a medium storing the relevant computer program, such as a USB flash drive or optical disc, or by a physical device integrating or installing the relevant computer program, such as a chip.

[0091] Furthermore, the message middleware in this embodiment includes multiple consumer groups, each consumer group corresponds to multiple consumer terminals, and the multiple consumer terminals corresponding to a consumer group can jointly consume all messages in the message middleware.

[0092] In this embodiment, the message push device can receive multiple messages sent by multiple servers. Each message contains an identifier of the target terminal to be pushed to. The identifier of the target terminal can be the target terminal ID or other suitable identifier, which is not limited in this embodiment.

[0093] To improve message push efficiency, the message push device can assign multiple received messages to pre-defined consumption groups. Multiple consumers corresponding to these groups then consume the messages based on the target terminal identifiers within the messages. During message consumption, the device pushes the messages to the target terminal based on the target terminal's communication protocol. This communication protocol is pre-stored on a server whose address corresponds to the target terminal identifier. The mapping between terminal identifiers and server addresses is pre-stored in a distributed cache. The specific implementation method for consumers to consume messages based on the target terminal identifiers and push messages has been described in detail in the above embodiments of this invention and will not be repeated here.

[0094] In one alternative implementation, in Figure 4 In step S402, the step of allocating the multiple messages to pre-specified consumer groups so that multiple consumer terminals corresponding to the consumer groups can consume the multiple messages includes: using a preset allocation strategy to allocate the multiple messages to pre-specified consumer groups so that each consumer terminal corresponding to the consumer groups can consume a portion of the multiple messages.

[0095] In this embodiment, the message push device can use a preset allocation strategy to distribute multiple messages to a pre-specified consumer group. The preset allocation strategy can be to distribute multiple messages evenly to multiple consumer terminals corresponding to the pre-specified consumer group, so that each consumer terminal corresponding to the consumer group can consume a portion of the multiple messages.

[0096] For example, if the message middleware receives 100 messages and there are 5 consumers in the pre-specified consumer group, the message push device can use a preset distribution strategy to distribute the 100 messages evenly to the 5 consumers in the pre-specified consumer group, that is, each consumer consumes 20 messages.

[0097] Specifically, in one example, the message push device can assign messages 1-20 from the message middleware to the first consumer, messages 21-40 to the second consumer, and so on, until messages 81-100 are assigned to the fifth consumer, thus completing the message allocation.

[0098] In another example, the message push device can distribute messages 1-5 in the message middleware to consumers 1-5 respectively, then distribute messages 6-10 to consumers 1-5 respectively, and so on, until messages 96-100 are distributed to consumers 1-5 respectively, thus completing the message distribution.

[0099] In another example, the message push device can also randomly select 20 messages from 100 messages in the message middleware and assign them to the first consumer, then randomly select 20 messages and assign them to the second consumer, and so on, until the last 20 messages are assigned to the fifth consumer, thus completing the message distribution.

[0100] The message push method provided in this embodiment receives multiple messages sent by multiple servers. Each message contains an identifier of the target terminal to be pushed to. Multiple messages are assigned to pre-specified consumer groups, allowing multiple consumers corresponding to each consumer group to consume the messages based on the target terminal identifiers. During message consumption, the messages are pushed to the target terminal based on the target terminal's communication protocol. The communication protocol is pre-stored on the server, which is the server address corresponding to the target terminal identifier. The mapping between terminal identifiers and server addresses is pre-stored in a distributed cache. In this method, each consumer does not need to connect to a fixed terminal. The message middleware can assign all messages to a pre-specified consumer group. Each consumer in this group only needs to consume a portion of the messages, and all consumed messages are accurately pushed to the corresponding target terminal without being discarded. This effectively avoids the time wasted on transmitting and judging messages that need to be discarded, thus improving the efficiency of message push.

[0101] In an optional implementation, the method further includes: for each message, determining whether the message has been successfully consumed; if the message has not been successfully consumed, storing the message in a delay queue so that the consumer can re-consume the message after a preset delay time.

[0102] In this embodiment, to avoid the problem of messages failing to be successfully pushed to the target terminal due to unsuccessful consumption by the consumer, the message push device can determine whether each message has been successfully consumed after message allocation. If a message is not successfully consumed, it is stored in a pre-set delay queue. After a preset delay time, the message push device can reassign the message to a consumer in a pre-specified consumption group, so that the consumer can re-consume the message after the preset delay time.

[0103] Based on the above embodiments, in an optional implementation, determining whether a message has been successfully consumed for each message includes: receiving an acknowledgment sequence number sent by the consumer; wherein each message corresponds to a different acknowledgment sequence number; for each message, determining whether the received acknowledgment sequence number contains the acknowledgment sequence number corresponding to the message; if not, determining that the message has not been successfully consumed; if so, determining that the message has been successfully consumed.

[0104] In this embodiment, in order to determine whether each message has been successfully consumed and delivered, the message push device can receive the confirmation sequence number sent by the consumer and determine whether the message has been successfully consumed based on the received confirmation sequence number.

[0105] In practical applications, when a consumer receives and consumes a message allocated by the message middleware, it can return a message to the message middleware. This message contains the acknowledgment sequence number of the message consumed by the consumer. Each message corresponds to a different acknowledgment sequence number, which can be consistent with the message's sequence number. For example, the acknowledgment sequence number corresponding to the first message in the message middleware can be 1.

[0106] After the message push device receives the acknowledgment sequence numbers sent by each consumer, it can determine for each message whether the received acknowledgment sequence numbers contain the acknowledgment sequence number corresponding to that message. In one possible scenario, if the received acknowledgment sequence numbers do not contain the acknowledgment sequence number corresponding to that message, it can be determined that the message was not successfully consumed by the consumer, and the message push device can store the message in a pre-set delay queue. In another possible scenario, if the received acknowledgment sequence numbers contain the acknowledgment sequence number corresponding to that message, it can be determined that the message has been successfully consumed by the consumer.

[0107] Continuing the previous example, after the message push device distributes 100 messages from the message middleware to the corresponding consumers in the pre-defined consumption groups, it can receive the message information returned by each consumer. Each consumer's returned message contains an acknowledgment sequence number for the message it has consumed. The message push device can first check if the received acknowledgment sequence number for the first message in the message middleware contains acknowledgment sequence number 1. If it does not contain acknowledgment sequence number 1, the first message is considered unsuccessfully consumed; if it does contain acknowledgment sequence number 1, the first message is considered successfully consumed. This process continues until the 100th message is successfully consumed.

[0108] The message push method provided in this embodiment determines whether a message has been successfully consumed by receiving an acknowledgment sequence number returned by the consumer. Unconsumed messages are stored in a delay queue so that the consumer can reconsuminate the message after a preset delay time. This effectively avoids the problem of messages failing to be successfully pushed to the target terminal due to unconsumed messages.

[0109] Figure 5 This is a schematic diagram of the structure of a message push device provided in an embodiment of the present invention, as shown below. Figure 5 As shown, the message push device provided in this embodiment is applied to a consumer end, which is located in a pre-specified consumer group. The device includes:

[0110] The acquisition module 51 is used to acquire the current message allocated by the message middleware, wherein the current message contains the identifier of the target terminal to be pushed.

[0111] The lookup module 52 is used to look up and obtain the server address corresponding to the identifier of the target terminal from the correspondence between terminal identifiers and server addresses pre-stored in a distributed cache, based on the identifier of the target terminal.

[0112] The acquisition module 51 is also used to obtain the server corresponding to the server address based on the routing mechanism, and to obtain the communication protocol corresponding to the identifier of the target terminal that is pre-stored from the server.

[0113] The push module 53 is used to push the current message to the target terminal using the communication protocol.

[0114] In the preferred technical solution of the aforementioned message push device applied to the consumer end, the acquisition module 51 is specifically used to acquire the pre-configured routing rules in the routing mechanism. The acquisition module 51 includes a lookup unit, used to reverse look up the server corresponding to the server address according to the routing rules; wherein, the pre-configured routing rules include the correspondence between the server and the server address.

[0115] In the preferred technical solution of the message push device applied to the consumer end described above, the acquisition module 51 further includes a connection unit for establishing a local connection with the server. Specifically, the acquisition module 51 is also used to acquire a pre-stored communication protocol corresponding to the identifier of the target terminal from the local cache of the server; the communication protocol corresponding to the identifier of the target terminal is stored in the local cache of the server when the target terminal initially establishes a connection with the server.

[0116] It should be noted that the technical solution and effects of the message push device applied to the consumer end provided in this embodiment can be found in the relevant content of the foregoing method embodiments, and will not be repeated here.

[0117] Figure 6 This is a schematic diagram of the structure of a message push device provided in an embodiment of the present invention, as shown below. Figure 6 As shown, the message push device provided in this embodiment is applied to a message middleware, which includes multiple consumer groups, each consumer group corresponding to multiple consumers; the device includes:

[0118] The receiving module 61 is used to receive multiple messages sent by multiple servers; each message contains the identifier of the target terminal to be pushed.

[0119] The allocation module 62 is used to allocate the multiple messages to a pre-specified consumption group, so that multiple consumers corresponding to the consumption group consume the multiple messages according to the identifier of the target terminal in the multiple messages, and push the messages to the target terminal based on the communication protocol of the target terminal when consuming the messages. The communication protocol is pre-stored on the server, and the server is the server address corresponding to the identifier of the target terminal. The correspondence between the terminal identifier and the server address is pre-stored in a distributed cache.

[0120] In the preferred technical solution of the message push device applied to the message middleware described above, the allocation module 62 is specifically used to allocate the multiple messages to a pre-specified consumption group using a preset allocation strategy, so that each consumer end corresponding to the consumption group consumes a portion of the multiple messages.

[0121] In the preferred embodiment of the message push device applied to the message middleware described above, the device further includes: a judgment module, used to determine whether the message has been successfully consumed for each message; and a storage module, used to store the message in a delay queue if the message has not been successfully consumed, so that the consumer can re-consume the message after a preset delay time.

[0122] In the preferred technical solution of the message push device applied to the message middleware described above, the judgment module includes a receiving unit for receiving an acknowledgment sequence number sent by the consumer; wherein each message corresponds to a different acknowledgment sequence number. Specifically, the judgment module is used to determine, for each message, whether the received acknowledgment sequence number contains the acknowledgment sequence number corresponding to the message; if it does not contain it, the message is determined to have not been successfully consumed; if it does contain it, the message is determined to have been successfully consumed.

[0123] It should be noted that the technical solution and effects of the message push device applied to the message middleware provided in this embodiment can be found in the relevant content of the foregoing method embodiments, and will not be repeated here.

[0124] Figure 7 This is a schematic diagram of an electronic device provided according to an embodiment of the present invention. This electronic device can be a consumer-grade device. Figure 7 As shown, the electronic device provided in this embodiment includes a memory 701 and a processor 702.

[0125] Memory 701 is used to store programs. Specifically, the program may include program code, which includes computer-executable instructions. Memory 701 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0126] Processor 702 is used to execute programs stored in memory 701.

[0127] The computer program is stored in memory 701 and configured to be executed by processor 702 to implement the present invention. Figure 3 The corresponding implementation provides a message push method. For related explanations, please refer to [link / reference]. Figure 3 The relevant descriptions and effects of the steps in the text will be understood, and will not be elaborated on here.

[0128] In this embodiment, the memory 701 and the processor 702 are connected via a bus. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0129] Figure 8 This is a schematic diagram of an electronic device provided according to an embodiment of the present invention. This electronic device can be a device corresponding to a consumer middleware. For example... Figure 8 As shown, the electronic device provided in this embodiment includes a memory 801 and a processor 802.

[0130] Memory 801 is used to store programs. Specifically, the program may include program code, which includes computer-executable instructions. Memory 801 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0131] Processor 802 is used to execute programs stored in memory 801.

[0132] The computer program is stored in memory 801 and configured to be executed by processor 802 to implement the present invention. Figure 4 The corresponding implementation provides a message push method. For related explanations, please refer to [link / reference]. Figure 4 The relevant descriptions and effects of the steps in the text will be understood, and will not be elaborated on here.

[0133] In this embodiment, the memory 801 and the processor 802 are connected via a bus. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0134] One embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the present invention. Figure 3 The corresponding implementation provides a message push method.

[0135] The computer-readable storage medium can be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0136] One embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the present invention. Figure 4 The corresponding implementation provides a message push method.

[0137] The computer-readable storage medium can be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0138] This invention provides an embodiment of a computer program product, including a computer program that is executed by a processor to implement the invention. Figure 3 The message push method provided in the corresponding embodiment 3.

[0139] This invention provides an embodiment of a computer program product, including a computer program that is executed by a processor to implement the invention. Figure 4 The message push method provided in the corresponding embodiment 4.

[0140] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0141] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the applications disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.

[0142] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

[0143] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the scope of protection of the present invention.

Claims

1. A message push method, characterized in that, The method is applied to the consumer end, which is located in a pre-defined consumption group of the message middleware. The message middleware receives multiple messages sent by multiple servers, each message containing an identifier of the target terminal to be pushed to, and assigns the multiple messages to the consumption group. The method includes: Obtain the current message allocated by the message middleware, wherein the current message contains the identifier of the target terminal to be pushed; Based on the identifier of the target terminal, the server address corresponding to the identifier of the target terminal is retrieved from the mapping relationship between terminal identifiers and server addresses pre-stored in the distributed cache. The server corresponding to the server address is obtained based on the routing mechanism, and the communication protocol corresponding to the identifier of the target terminal is obtained from the server in advance; wherein, the communication protocol is the protocol negotiated and stored in the local cache of the server when the target terminal and the server first establish a connection; the communication protocol is the WebSocket communication protocol; The current message is pushed to the target terminal using the aforementioned communication protocol.

2. The method according to claim 1, characterized in that, The step of obtaining the server corresponding to the server address based on the routing mechanism includes: Obtain the pre-configured routing rules in the routing mechanism; According to the routing rules, the server corresponding to the server address is obtained by reverse lookup; wherein, the pre-configured routing rules include the correspondence between the server and the server address.

3. A message push method, characterized in that, The method is applied to a message middleware, which includes multiple consumer groups, each consumer group corresponding to multiple consumers; the method includes: It can receive multiple messages from multiple servers; each message contains the identifier of the target terminal to be pushed to. Based on the target terminal identifier contained in each of the multiple messages, and combined with the correspondence between terminal identifiers and server addresses pre-stored in the distributed cache, the target consumption group to which each message should be assigned is determined. The multiple messages are assigned to the determined target consumption group so that the consumer terminal corresponding to the target consumption group can query the server address and communication protocol based on the identifier of the target terminal, and push messages using the communication protocol; wherein, the communication protocol is the WebSocket communication protocol, and is the protocol negotiated and stored in the local cache of the server when the target terminal and the corresponding server establish a connection for the first time.

4. The method according to claim 3, characterized in that, Assigning the multiple messages to the determined target consumption group includes: for messages assigned to the same target consumption group, using a preset allocation strategy to assign them to multiple consumers corresponding to the target consumption group, so that each consumer consumes a portion of the messages.

5. The method according to claim 3, characterized in that, The method further includes: For each message, determine whether the message has been successfully consumed; If the message is not successfully consumed, it is stored in a delay queue so that the consumer can re-consume the message after a preset delay time.

6. The method according to claim 5, characterized in that, The step of determining whether a message has been successfully consumed for each message includes: Receive the confirmation sequence number sent by the consumer; wherein, each message corresponds to a different confirmation sequence number; For each message, determine whether the received acknowledgment sequence number contains the acknowledgment sequence number corresponding to the message; If not included, it is determined that the message was not successfully consumed; If the message is included, then the message consumption is considered successful.

7. A message push device, characterized in that, The device is applied to the consumer end, which is located in a pre-defined consumption group of the message middleware. The message middleware receives multiple messages sent by multiple servers, each message containing an identifier of the target terminal to be pushed to, and assigns the multiple messages to the consumption group. The device includes: The acquisition module is used to acquire the current message allocated by the message middleware, wherein the current message contains the identifier of the target terminal to be pushed; The lookup module is used to search for and obtain the server address corresponding to the identifier of the target terminal from the mapping relationship between terminal identifiers and server addresses pre-stored in a distributed cache based on the identifier of the target terminal. The acquisition module is further configured to obtain the server corresponding to the server address based on a routing mechanism, and obtain the communication protocol corresponding to the identifier of the target terminal from the server; wherein, the communication protocol is a protocol negotiated and stored in the local cache of the server when the target terminal and the server first establish a connection; the communication protocol is the WebSocket communication protocol; The push module is used to push the current message to the target terminal using the communication protocol.

8. A message push device, characterized in that, The device is applied to a message middleware, which includes multiple consumer groups, each consumer group corresponding to multiple consumers; the device includes: The receiving module is used to receive multiple messages sent by multiple servers; each message contains the identifier of the target terminal to be pushed to. The allocation module is used to determine the target consumer group to which each message should be allocated based on the identifier of the target terminal contained in each of the multiple messages, combined with the correspondence between terminal identifiers and server addresses pre-stored in a distributed cache; and to allocate the multiple messages to the determined target consumer groups, so that the consumer terminal corresponding to the target consumer group can query the server address and communication protocol based on the identifier of the target terminal, and push messages using the communication protocol; wherein, the communication protocol is the WebSocket communication protocol, and is the protocol negotiated and stored in the local cache of the server when the target terminal and the corresponding server first establish a connection.

9. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the message push method as described in any one of claims 1-2 or 3-6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the message push method as described in any one of claims 1-2 or 3-6.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the message push method as described in any one of claims 1-2 or 3-6.

Citation Information

Patent Citations

  • Message pushing method and device, equipment and storage medium

    CN111711697A