Multi-user message push method and push system based on publish-subscribe mode
By adopting a multi-user message push method and system based on the publish-subscribe model in the government service system, the problem of users having difficulty receiving messages of interest and being disturbed by spam messages is solved, achieving accurate message sending and receiving, and improving user experience. and system performance.
Patent Information
- Application Number
- CN202111046838.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-06
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2041-09-06
AI Technical Summary
In the government service system, it is difficult for users to effectively receive message notifications of interest, while avoiding being disturbed by spam messages, affecting the user experience.
Adopt a multi-user message push method and system based on the publish-subscribe model. The message publisher collects the needs of subscribers, formulates subscription topics and sets personalized message notification formats. Message subscribers subscribe or unsubscribe topics based on interests, and use distributed Message queue performs message distribution and push.
It achieves accurate message sending and receiving based on message topics, improves user experience, reduces information noise, and improves the scalability and reliability of the system.
Smart Images

Figure CN113905089B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of message user push, in particular to a multi-user message push method and a push system based on a publish-subscribe mode. Background Art
[0002] With the advancement of the construction of integrated government services, government service platforms at all levels have become mature, but users have higher and higher requirements for the convenience and practicality of services. However, users will inevitably encounter such embarrassing situations when using the system: they cannot receive the desired message notifications during use, which affects the user experience. Users hope to be able to check some important messages in time while avoiding being disturbed by some spam messages. The emergence of a good feedback method will directly affect the quality of the website and the quality of the system to a certain extent. Feedback interaction is based on the design concept centered on the user experience, showing specific design details and creating a good user experience.
[0003] Based on the above analysis, how to send and receive messages based on the subject of the message is a technical problem that needs to be solved. Summary of the invention
[0004] The technical task of the present invention is to address the above shortcomings and provide a multi-user message push method and push system based on the publish-subscribe model to solve the problem of how to send and receive messages based on the subject of the message.
[0005] In a first aspect, a multi-user message push method based on a publish-subscribe mode of the present invention comprises the following steps:
[0006] The message publisher collects the needs of message subscribers, formulates subscription topics, and sets personalized message notification formats based on the subscription topics;
[0007] The message subscriber subscribes to or unsubscribes from a topic based on its interest, and generates a corresponding topic subscription state, wherein the topic subscription state is used to indicate the subscription or unsubscription status of each message subscriber to each subscription topic;
[0008] The subscription topic, message notification format and topic subscription status are stored in a message subscription list;
[0009] The message publisher pushes the messages it produces to the message queue, which is a distributed message queue. The message queue stores the received messages in its memory queue.
[0010] Each message is distributed based on content and subject, and pushed to the corresponding message subscribers in conjunction with the message subscription list.
[0011] Preferably, the message publisher collects the needs of the message subscribers and formulates a subscription topic for the content whose access volume or query rate meets the threshold.
[0012] Preferably, the message notification format includes message content, message type, sending location, sending time and message level.
[0013] Preferably, the message queue receives and pushes messages based on a first-in-first-out manner.
[0014] Preferably, the message producer pushes the message it produces to the virtual machine, and the virtual machine routes the message to the corresponding message queue through the switch.
[0015] Preferably, before each message is pushed to the corresponding message subscriber, a filtering operation is performed on the message, and the filtering operation includes the following steps:
[0016] Sort messages;
[0017] Configure the priority of messages and process them based on the priority queue mode;
[0018] Detection and deletion of duplicate messages based on message ID and retrograde duplicate messages to delete duplicate messages;
[0019] Perform poisonous message detection and delete messages with incorrect formats or messages that require access to unavailable resources.
[0020] Based on the message lifecycle configured by the message subscriber, check whether the message is expired and delete the expired message.
[0021] In a second aspect, the multi-user message push system based on the publish-subscribe mode of the present invention comprises:
[0022] A message publishing module, which is oriented to message publishers and configured on corresponding message publisher application servers. Message publishers collect message subscribers' needs through the message publishing module, formulate subscription topics, and set personalized message notification formats according to subscription topics. Message publishers produce and publish messages through the message publishing module;
[0023] A message subscription module, wherein the message receiving module is oriented to the message subscriber and is configured in the corresponding message subscriber application server. The message subscriber subscribes to or unsubscribes from a topic based on its interest through the message subscription module, and generates a corresponding topic subscription status. The message subscriber receives messages through the message subscription module;
[0024] A message push list, which is configured in a corresponding message queue application server and is used to store the subscription topic, message notification format and topic subscription status;
[0025] Message queue, the message queue is a distributed message queue and is configured in the corresponding message queue application server, the message subscription module is used to call the message sending interface to send the message generated by the message subscriber to the message queue, and the message queue stores the received message in its memory queue;
[0026] A message push module, which is configured in the corresponding message queue application server, is used to distribute each message based on content and subject, and push each message to the corresponding message subscriber through the message push interface in cooperation with the message subscription list;
[0027] The message monitoring module is used to filter messages. The filtering operation includes the following steps:
[0028] Sort messages;
[0029] Configure the priority of messages and process them based on the priority queue mode;
[0030] Detection and deletion of duplicate messages based on message ID and retrograde duplicate messages to delete duplicate messages;
[0031] Perform poisonous message detection and delete messages with incorrect formats or messages that require access to unavailable resources.
[0032] Based on the message lifecycle configured by the message subscriber, check whether the message is expired and delete the expired message.
[0033] Preferably, the message publisher collects the needs of message subscribers through the message publishing module, and formulates subscription topics for the content whose visit volume or query rate meets the threshold.
[0034] Preferably, the message notification format includes message content, message type, sending location, sending time and message level;
[0035] Message queues receive and push messages based on a first-in-first-out basis.
[0036] As a preference, it also includes:
[0037] A virtual machine, at least one of the virtual machines, configured in a message queue application server, for obtaining a message produced by a message producer from a message subscription module through a message receiving interface;
[0038] The switch is configured on the message queue application server and interacts with the switch, and is used to cooperate with the message push list to route the message to the corresponding message channel, and push the message to the corresponding message subscriber through the message channel.
[0039] The multi-user message push method and push system based on the publish-subscribe mode of the present invention have the following advantages:
[0040] 1. The publish / subscriber model can decouple many subsystems that need to communicate, and each subsystem can be managed independently. Even if some subsystems are offline, it will not affect the overall management of system messages, providing separation of concerns for applications. Each application can focus on its core functions, while the messaging infrastructure is responsible for routing messages to each consumer;
[0041] 2. Improves the scalability of the system and improves the responsiveness of the sender. The reason is that the sender can quickly send a message to the input channel and then return to its core processing responsibilities without having to wait for the subsystem to complete the processing. The messaging infrastructure is then responsible for ensuring that the message is delivered to each subscriber;
[0042] 3. The publish / subscribe model improves reliability. Asynchronous messaging helps applications continue to run smoothly under increased load and can handle intermittent failures more effectively;
[0043] 4. The publish / subscribe pattern allows for delayed processing or scheduled processing. For example, when the system is heavily loaded, subscribers can wait until off-peak hours to receive messages, or process messages according to a specific plan;
[0044] 5. Improved testability. Channels can be monitored and messages can be checked or recorded as part of the overall integration testing strategy. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] The present invention is further described below in conjunction with the accompanying drawings.
[0047] Figure 1 This is a flowchart of a multi-user message push method based on a publish-subscribe model according to Embodiment 1;
[0048] Figure 2 This is a flowchart of the publish-subscribe process in the multi-user message push method based on the publish-subscribe mode in Example 1.
[0049] Figure 3 This is a block diagram of the working principle of a multi-user message push system based on a publish-subscribe model in Example 2. DETAILED DESCRIPTION
[0050] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments may be combined with each other.
[0051] The embodiment of the present invention provides a multi-user message push method based on a publish-subscribe mode, which is used to solve the technical problem of how to send and receive messages based on the subject of the message.
[0052] Embodiment 1:
[0053] like Figure 1 and Figure 2 As shown, the multi-user message push method based on the publish-subscribe mode of the present invention comprises the following steps:
[0054] S100, the message publisher collects the needs of the message subscribers, formulates the subscription topic, and sets a personalized message notification format according to the subscription topic;
[0055] Message subscribers subscribe to or unsubscribe from topics based on their interests and generate corresponding topic subscription states, which are used to indicate the subscription or unsubscription status of each message subscriber to each subscribed topic.
[0056] The subscription topic, message notification format and topic subscription status are stored through the message subscription list;
[0057] S200, the message publisher pushes the message it produces to the message queue, which is a distributed message queue. The message queue stores the received message in its memory queue;
[0058] S300: Distribute each message based on content and subject, and push each message to a corresponding message subscriber in conjunction with a message subscription list.
[0059] In step S100, the message publisher performs subscription management. The message publisher collects user (i.e., message subscriber) requirements and formulates subscription topics for content with high visit volume or query rate. Subscribers can subscribe or unsubscribe to a topic in the message channel. Topics make the message subscribers and message publishers independent of each other, and the message delivery can be guaranteed without contact.
[0060] At the same time, the message publisher configures the message and sets a personalized message notification format according to different subscription topics, including: message content, message type, sending location, sending time, message level, etc.
[0061] In step S300, the message queue checks and distributes the messages after receiving them, and checks and distributes the messages according to the content of each message. Each subscriber can specify the content he is interested in. There are two commonly used filtering forms: topic-based and content-based.
[0062] In a topic-based system, messages are published to topics or named channels. Subscribers will receive all messages on the topics they subscribe to, and all subscribers to the same topic will receive the same messages. The publisher is responsible for defining the message categories to which subscribers subscribe.
[0063] In a content-based system, subscribers define conditions for messages they are interested in, and messages are delivered to subscribers only when the attributes or content of the message meet the conditions defined by the subscriber. Subscribers are responsible for classifying messages. The system supports a mix of the two: publishers publish messages to topics, and subscribers register content-based subscriptions to one or more topics.
[0064] A message queue is used to store messages until they are sent to consumers. It is a container for messages and also the destination of messages. A message can be put into one or more queues. The message is always in the queue, waiting for consumers to connect to the queue and take it away.
[0065] Message queues provide a one-step communication protocol, which means that the sender and receiver of a message do not need to keep in touch with the message at the same time. The sender's message will be stored in the queue until the receiver gets it. The sender of a message is generally called a producer, and the receiver of a message is called a consumer. Since the producers and consumers are opaque, they are connected by the middle link - the message queue.
[0066] Distributed message queues can be seen as deploying this data structure on an independent server, using distributed message queues through remote access interfaces to perform message storage operations, and then implement distributed asynchronous calls. Correspondingly, the workflow is:
[0067] (1) The message producer application pushes the message to the message queue server through the remote access interface. The message queue server writes the message into the local memory queue and immediately returns a successful response to the message producer.
[0068] (2) The message queue server searches for the consumer application that subscribes to the message according to the message subscription list, and sends the message in the message queue to the consumer application through the remote communication interface according to the first-in-first-out principle;
[0069] (3) After receiving the pushed message, the consumer application performs a series of related processing and the process terminates.
[0070] When a message publisher pushes a message to a message queue, the message producer first produces a message and sends it to a virtual host in the message proxy (server). The virtual host has switches and queues. The virtual host sends the message to the specified switch, and the switch determines which message queue to route the message to based on the routing key of the message. The routing rules are represented by binding relationships. When a message arrives at the message queue, the consumer can take the message from the message queue. The consumer establishes a connection with the message queue. In order to save resources, multiple channels are opened in each TCP connection, and data is transmitted to the consumer through the channel.
[0071] As an improvement, in order to improve the effectiveness of message publishing, each message is filtered before being pushed to the corresponding message subscriber. The filtering operation includes the following steps:
[0072] (1) Ordering messages. The order in which messages are received by consumer instances is not necessarily guaranteed, nor does it necessarily reflect the order in which the messages were created. This approach is designed to ensure that message processing is equal to help eliminate any dependency on the order in which messages are processed.
[0073] (2) Configuring message priorities and processing messages based on a priority queue model. The priority queue model provides a mechanism to ensure that specific messages are delivered before other messages.
[0074] (3) Detection and deletion of duplicate messages based on message IDs and retroactive duplicate messages to remove duplicate messages. The same message may be sent multiple times. For example, the sender may have an exception after publishing the message and fail to record that it has successfully sent the message. Then, a new instance of the sender may start and repeat the message. The message infrastructure should implement duplicate message detection and deletion (also known as deduplication) based on the message ID to provide at most once message delivery;
[0075] (4) Perform poisonous message detection to delete messages with incorrect formats or messages that require access to unavailable resource tasks, to prevent such messages from returning to the queue, which could cause system failures;
[0076] (5) Based on the message lifecycle configured by the message subscriber, check whether the message is expired and delete the expired message. The lifecycle of a message may be limited. If it is not processed within this period of time, it may no longer be valuable and should be discarded. The sender can specify the expiration time as part of the data in the message. Before deciding whether to execute the business logic associated with the message, the receiver can check this information to ensure that the message has not expired.
[0077] The multi-user message push method based on the publish / subscribe mode of this embodiment enables the distribution of messages to break through the geographical limitation of the destination queue, so that messages can be distributed according to specific topics or even contents, and users or applications can receive the required messages according to the topics or contents.
[0078] The publish / subscribe model makes the coupling relationship between the sender and the receiver looser. The sender does not need to care about the destination address of the receiver, and the receiver does not need to care about the sending address of the message. Instead, the message is sent and received based on the subject of the message. In order to facilitate users to receive message reminders, it is necessary to configure relevant subscription topics in advance according to user needs for users to choose. The following is an example of an applicant subscribing to the "Policy and Regulation Interpretation" topic:
[0079] (1) Configure the "Policy and Regulation Interpretation" template in the subscription topic template configuration;
[0080] (2) In the message template configuration, configure "Hello user, the following is the latest policy and regulatory interpretation message, please click to view";
[0081] (3) Publish relevant policy interpretation information in the “Policy and Regulation Interpretation” theme template configuration.
[0082] (4) Enable scheduled message sending in the message sending configuration to send message reminders to subscribed users.
[0083] Embodiment 2:
[0084] like Figure 3As shown, the multi-user message push system based on the publish-subscribe mode of the present invention includes a message publishing module, a message subscription module, a message push list, a message queue, a message push module, and a message monitoring module. The message publishing module is oriented to the message publisher and is configured on the corresponding message publisher application server. The message publisher collects the needs of the message subscriber through the message publishing module, formulates the subscription topic, and sets the personalized message notification format according to the subscription topic. The message publisher produces and publishes messages through the message publishing module; the message receiving module is oriented to the message subscriber and is configured on the corresponding message subscriber application server. The message subscriber subscribes or unsubscribes from the topic based on its interest through the message subscription module, and generates the corresponding Topic subscription status, message subscribers receive messages through the message subscription module; the message push list is configured in the corresponding message queue application server, which is used to store the subscription topic, message notification format and topic subscription status; the message queue is a distributed message queue and is configured in the corresponding message queue application server, the message subscription module is used to call the message sending interface to send the message produced by the message subscriber to the message queue, and the message queue stores the received message in its memory queue; the message push module is configured in the corresponding message queue application server, which is used to distribute each message based on content and topic, and cooperate with the message subscription list to push each message to the corresponding message subscriber through the message push interface.
[0085] The message monitoring module is used to filter messages. The filtering operation includes the following steps:
[0086] (1) Sort messages;
[0087] (2) Configure the priority of the message and process the message based on the priority queue mode;
[0088] (3) Detection and deletion of duplicate messages based on message ID and retrograde duplicate messages to delete duplicate messages;
[0089] (4) Perform poisonous information detection and delete messages with incorrect formats or messages that require access to unavailable resource tasks;
[0090] (5) Based on the message lifecycle configured by the message subscriber, check whether the message is expired and delete the expired message.
[0091] The message publisher collects the needs of message subscribers through the message publishing module and formulates subscription topics for content whose visit volume or query rate meets the threshold.
[0092] The message notification format includes message content, message type, sending location, sending time, and message level.
[0093] Message queues receive and push messages based on a first-in-first-out basis.
[0094] In this embodiment, there is also a switch and at least one virtual machine. The virtual machine is configured on the message queue application server and is used to obtain messages produced by the message producer from the message subscription module through the message receiving interface; the switch is configured on the message queue application server and interacts with the switch, and is used to cooperate with the message push list to route the message to the corresponding message channel, and push the message to the corresponding message subscriber through the message channel.
[0095] The multi-user message push system based on the publish-subscribe mode of this embodiment can execute the multi-user message push method based on the publish-subscribe mode disclosed in Embodiment 1.
[0096] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.
Claims
1. A multi-user message push method based on publish-subscribe mode, characterized in that The steps include: The message publisher collects the needs of message subscribers, formulates subscription topics for content with visit volume or query rate that meets the threshold, and sets a personalized message notification format based on the subscription topic. The message notification format includes message content, message type, sending location, sending time and message level; The message subscriber subscribes to or unsubscribes from a topic based on its interest, and generates a corresponding topic subscription state, wherein the topic subscription state is used to indicate the subscription or unsubscription status of each message subscriber to each subscription topic; The subscription topic, message notification format and topic subscription status are stored in a message subscription list; The message publisher pushes the messages it produces to the message queue, which is a distributed message queue. The message queue stores the received messages in its memory queue. The message queue receives and pushes messages based on a first-in-first-out method. Distribute each message based on content and subject, and push each message to the corresponding message subscribers in conjunction with the message subscription list; Before each message is pushed to the corresponding message subscriber, the message is filtered. The filtering operation includes the following steps: Sort messages; Configure the priority of messages and process them based on the priority queue mode; Detection and deletion of duplicate messages based on message ID and retrograde duplicate messages to delete duplicate messages; Perform poisonous message detection and delete messages with incorrect formats or messages that require access to unavailable resources. Based on the message lifecycle configured by the message subscriber, check whether the message is expired and delete the expired message.
2. The multi-user message push method based on the publish-subscribe mode according to claim 1 is characterized in that The message producer pushes the messages it produces to the virtual machine, and the virtual machine routes the messages to the corresponding message queue through the switch.
3. A multi-user message push system based on publish-subscribe mode, characterized by include: A message publishing module, which is oriented to the message publisher and configured on the corresponding message publisher application server. The message publisher collects the needs of message subscribers through the message publishing module, formulates subscription topics for content with visit volume or query rate meeting the threshold, and sets a personalized message notification format according to the subscription topic. The message publisher produces and publishes messages through the message publishing module. The message notification format includes message content, message type, sending location, sending time and message level; A message subscription module, which is oriented to message subscribers and configured in a corresponding message subscriber application server. Message subscribers subscribe to or unsubscribe from topics based on their interests through the message subscription module, and generate corresponding topic subscription status. Message subscribers receive messages through the message subscription module; A message push list, which is configured in a corresponding message queue application server and is used to store the subscription topic, message notification format and topic subscription status; Message queue, which is a distributed message queue and is configured on a corresponding message queue application server. The message subscription module is used to call a message sending interface to send messages generated by message subscribers to the message queue. The message queue stores received messages in its memory queue. The message queue receives and pushes messages based on a first-in-first-out method. A message push module, which is configured in the corresponding message queue application server, is used to distribute each message based on content and subject, and push each message to the corresponding message subscriber through the message push interface in cooperation with the message subscription list; The message monitoring module is used to filter messages. The filtering operation includes the following steps: Sort messages; Configure the priority of messages and process them based on the priority queue mode; Detection and deletion of duplicate messages based on message ID and retrograde duplicate messages to delete duplicate messages; Perform poisonous message detection and delete messages with incorrect formats or messages that require access to unavailable resources. Based on the message lifecycle configured by the message subscriber, check whether the message is expired and delete the expired message.
4. The multi-user message push system based on the publish-subscribe model according to claim 3 is characterized in that Also includes: A virtual machine, at least one of the virtual machines, configured in a message queue application server, for obtaining a message produced by a message producer from a message subscription module through a message receiving interface; The switch is configured on the message queue application server and interacts with the switch, and is used to cooperate with the message push list to route the message to the corresponding message channel, and push the message to the corresponding message subscriber through the message channel.
Citation Information
Patent Citations
Posting / subscribing system for adding message queue models and working method thereof
CN104092767A
Publish / subscribe system and method for managing subscriptions
CN1953426A