CN-119676292-B - Method, device and system for pushing long connection message in dual-site environment
Abstract
The invention relates to the technical field of Internet, in particular to a method, a device and a system for pushing long connection messages in a double-site environment. In the invention, the long connection instance consumed for the first time is responsible for the message, the long connection push service is regarded as a unified whole, the message middleware decoupling and the message redelivery mechanism are combined, and the problem of double-site load balancing invalidation under the high concurrency condition is effectively solved through the redelivery mode of the message. Under the cooperation of double measures of message middleware and message redelivery, the consistency of the connection service and the message pushing service can be ensured to be established by a user, thereby realizing high-efficiency long-connection pushing in a double-site environment and ensuring the message pushing accuracy in the double-site environment. The invention solves the problem of lacking a long connection message pushing effective scheme in a double-station environment.
Inventors
- FENG WEIQIANG
- ZHAO LEI
- WANG RUI
- HUANG YAJUN
Assignees
- 合肥大智慧财汇数据科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20241212
Claims (9)
- 1. A long connection message pushing method in a double-station environment is characterized in that: When a user is online, adding any long connection example, wherein the user connection information is recorded by Redis; Defining a long connection instance of consumption as a principal when a message producer sends a message associated with the user; judging whether the principal is a long connection instance associated with the user; if yes, the principal sends the message to the user; If not, the principal inquires Redis to acquire the long connection instance information of the user connection, and sends the message to the long connection instance associated with the user through a message middleware; The method comprises the following steps: S1, a service registration center configures a message middleware and a long connection instance, and configures a binding relation between the message middleware and the long connection instance; s2, the message middleware monitors a message producer and receives the message, and the long connection instance randomly consumes the message from the message middleware and extracts a designated user from the message; S3, the long connection instance judges whether the appointed user exists in the user set bound by the appointed user; If yes, the long connection instance sends the message to the appointed user; If not, executing step S4; S4, inquiring the long connection instance bound by the appointed user, and then sending the message and the long connection instance bound by the appointed user to the message middleware; And S5, the message middleware sends the message to the long-length connection instance bound by the appointed user, and the long-length connection instance bound by the appointed user sends the message to the appointed user.
- 2. The long connection message push method in a dual-site environment of claim 1 wherein a service registry employs Nacos, zookeeper or Consul.
- 3. The method for pushing long connection messages in a dual-site environment according to claim 1, wherein message middleware adopts RabbitMQ, rocketMQ or Kafka.
- 4. The long connection message pushing method in a dual site environment of claim 1, wherein Redis is set to dual active synchronization.
- 5. The long connection message pushing method in a dual site environment of claim 1, wherein the user connection information comprises user identity information session.
- 6. A long connection message pushing method in a dual site environment as recited in any of claims 1-5, wherein message producers steal SDK interface box message middleware send messages.
- 7. A long connection message pushing device under a double site environment, which adopts the long connection message pushing method under the double site environment as set forth in any one of claims 1-6, is applied to a load balancing module, and is characterized by comprising a request monitoring unit, a user monitoring unit and a message distributing unit; The system comprises a request monitoring unit, a message distribution unit, a user connection unit and a user connection unit, wherein the request monitoring unit is used for monitoring a message push request of a message producer and notifying the message distribution unit, and is also used for monitoring a user connection request; The user monitoring unit is used for acquiring a user connection request and the online condition of the user, and distributing a long connection instance to the user for binding when the user connection request is acquired; and the message distribution unit is used for sending the message and the message pushing request to the message middleware and notifying the long connection instance to consume.
- 8. The long-connection message pushing system in the double-site environment is characterized by comprising a message pushing device, a message consumption module, a message sending module and a database module; The message pushing device adopts the long-connection message pushing device under the dual-site environment as claimed in claim 7, and comprises a request monitoring unit, a user monitoring unit and a message sending unit; the database module is used for acquiring the binding information of the user and the long connection instance generated by the user monitoring unit and storing the user identity information and the binding information; the message consumption module is used for managing consumption information of the long connection instance from the message middleware, and only one long connection instance consumes each message so as to avoid congestion caused by simultaneous consumption of a plurality of long connection instances; And the message sending module is used for sending the message consumed by the long connection instance to the user appointed by the message.
- 9. The long connection message push system in a dual site environment of claim 8, further comprising a log monitor management platform for logging log information.
Description
Method, device and system for pushing long connection message in dual-site environment Technical Field The invention relates to the technical field of Internet, in particular to a method, a device and a system for pushing long connection messages in a double-site environment. Background With the development of internet technology, particularly the mobile internet and the rising of real-time applications, the requirements of users on the real-time property and the interactivity of information are increasing. The traditional client polling request mode has poor real-time performance, can not meet the requirements of modern applications, and can cause unnecessary resource consumption due to frequent requests. Especially in the context of multi-environment deployment, where two or more environments exist that are independent of each other but need to work in concert (e.g., development environments, testing environments, production environments, etc.), ensuring consistency and accuracy of push of messages across environments is a great challenge. Particularly in the long connection push service, because the generation and consumption of the message may occur in different environments, the route and the user side are easily and wrongly identified, thereby causing the message to be missed or wrongly sent. In view of the above problems, many solutions are currently proposed, such as: the WebSocket protocol is used as the basis of real-time communication, and the WebSocket provides a low-delay data transmission channel, so that the WebSocket protocol is a key technology for realizing long connection message pushing; Message queues such as RabbitMQ, kafka and the like, which are used for asynchronously transferring messages between a producer and a consumer and realizing the storage and distribution of the messages; the event-driven architecture is characterized in that a system component can respond to a specific event through an event triggering mechanism without continuous inquiry or polling, so that the response speed and the response efficiency of the system are improved; The load balancing technology is that client requests are dispersed through a load balancer (such as Nginx, HAProxy), so that high availability and stability of the service are ensured; The distributed system and micro-service architecture is that the system is decomposed into a plurality of independent services, each service is responsible for a part of functions, and communication is carried out through an API, so that the expandability and flexibility of the system are enhanced; security mechanisms including, but not limited to, TLS/SSL encryption, OAuth authentication, JWT (JSON Web Tokens), etc., ensure secure transmission of data and verification of user identity. The long connection service adopts a technical strategy of double-station maintenance. The long connection service in the dual-site environment cannot intelligently sense the geographic site where the user is located, so that unnecessary repeated pushing of messages is caused, resources are consumed, and efficiency is affected. The solution can improve the success rate and the efficiency of message transmission in a specific environment, but hardly achieves the expected effect in a double-station environment and is more suitable for a short connection message pushing mode. In a word, the success rate and timeliness of the existing long connection message push in the dual-site environment are difficult to guarantee, and the prior art lacks solutions. Disclosure of Invention In order to overcome the defect that the prior art has no effective scheme for pushing the long connection message in the dual-site environment, the invention provides a method for pushing the long connection message in the dual-site environment, which has expandability and robustness, can ensure that the message can be correctly identified and pushed, and ensures the timeliness and the accuracy of pushing the long connection message in the dual-site environment. The invention provides a long connection message pushing method under a double-station environment, which comprises the following steps: When a user is online, adding any long connection example, wherein the user connection information is recorded by Redis; Defining a long connection instance of consumption as a principal when a message producer sends a message associated with the user; judging whether the principal is a long connection instance associated with the user; if yes, the principal sends the message to the user; If not, the principal inquires Redis to acquire the long connection instance information of the user connection, and sends the message to the long connection instance associated with the user through the message middleware, and the long connection instance associated with the user sends the message to the user. Preferably, the method comprises the following steps: S1, a service registration center configures a message middleware and