CN111917687B - Method and device for circularly pushing reminding message - Google Patents

Method and device for circularly pushing reminding message Download PDF

Info

Publication number
CN111917687B
CN111917687B CN201910378895.5A CN201910378895A CN111917687B CN 111917687 B CN111917687 B CN 111917687B CN 201910378895 A CN201910378895 A CN 201910378895A CN 111917687 B CN111917687 B CN 111917687B
Authority
CN
China
Prior art keywords
message
reminded
route
push request
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910378895.5A
Other languages
Chinese (zh)
Other versions
CN111917687A (en
Inventor
史贤伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN201910378895.5A priority Critical patent/CN111917687B/en
Publication of CN111917687A publication Critical patent/CN111917687A/en
Application granted granted Critical
Publication of CN111917687B publication Critical patent/CN111917687B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/55Push-based network services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Transfer Between Computers (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a method and a device for circularly pushing reminding messages, and relates to the technical field of computers. One embodiment of the method comprises the following steps: receiving a cyclic push request, analyzing the cyclic push request to determine parameter information of the cyclic push request, wherein the parameter information at least comprises a cyclic period, a route identifier and a message to be reminded; according to the cycle period and the route identification, searching corresponding route information in a first database at regular time; the first database is used for storing the route information of the front end when the front end establishes connection with a service node in the distributed service cluster; and calling a service node in the distributed service cluster according to the routing information, so that the service node pushes the message to be reminded to the corresponding front end. The method can send the reminding message to the front end of any business and connection, solves the problem of the increase of the pressure of the server and the database caused by repeated polling of the server in the prior art, and is convenient for development and maintenance.

Description

Method and device for circularly pushing reminding message
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for circularly pushing a reminder message.
Background
With the development of business, the requirements of many business scenes on timeliness are continuously improved, such as order taking, order delivery and the like. When the bill is issued to the operation end system, the service scenes need to push reminding information to the corresponding operation end so as to remind operators to process as soon as possible. Because the environmental difference of the operation site is large, the reminding message needs to be circularly reminded for a plurality of times until an operator processes the service, so that the service is ensured to be carried out within a specified time.
The existing mode of circularly pushing reminding information by the working end mainly comprises the following steps: and carrying out message reminding in a mode of regularly sending an ajax request to poll the server in a JavaScript code of the front-end browser, wherein polling means that the client regularly sends the ajax request to the server, and the server returns response information and closes the connection immediately after receiving the request. The server side inquires the related data of the service corresponding to the request from the database after receiving the request, returns information to the front end according to the inquired data, and judges whether reminding is needed after the front end is connected with the server side for response. The server returns a flag that the data is "have" or "do not" such as true or false, and then the front end receives the response of the server, if true, the front end carries out reminding, if false, the front end does not carry out reminding, and the specific reminding mode is processed by the front end.
The above prior art has the following technical problems: multiple polling of the server may result in increased pressures on the server and database, which is particularly problematic when the concurrency increases; defining the time interval of message reminding into a front-end JavaScript code, and defining a plurality of timers to send ajax requests at the front end if a plurality of businesses need to be reminded and the reminding period is inconsistent, so that the resource waste is caused, and the development and the maintenance are inconvenient; because different data needs to be queried for unused service reminding, the existing scheme needs to define a query service for each service, and development and maintenance are very inconvenient.
Disclosure of Invention
In view of this, the embodiments of the present invention provide a method and an apparatus for circularly pushing a reminder message, which can directly determine corresponding routing information according to parameter information of a parsed circularly pushing request, and push a reminder message in the parameter information to a front end according to the routing information, where a back end service does not need to define a query service. The front end of any service and connection can be pushed with reminding information, a plurality of timers are not required to be defined at the front end, an interface is not required to be specially defined for polling the front end, and the front end is not required to judge which needs to be reminded, how to remind and the like. The problem of the prior art that the server side is polled for multiple times to cause the increase of the pressure of the server side and the database is solved, and the development and the maintenance are convenient.
In order to achieve the above object, according to an aspect of the embodiments of the present invention, a method for circularly pushing a reminder message is provided.
The method for circularly pushing the reminding message comprises the following steps: receiving a cyclic push request, analyzing the cyclic push request to determine parameter information of the cyclic push request, wherein the parameter information at least comprises a cyclic period, a route identifier and a message to be reminded; according to the cycle period and the route identification, searching corresponding route information in a first database at regular time; the first database is used for storing the route information of the front end when the front end establishes connection with a service node in the distributed service cluster; and calling a service node in the distributed service cluster according to the routing information, so that the service node pushes the message to be reminded to the corresponding front end.
Optionally, the step of searching the first database for the corresponding routing information periodically according to the cycle period and the routing identifier includes: sending the message to be reminded of the received cyclic push request to a message queue; consuming the message to be reminded in the message queue, and generating a delayed pushing task according to the cycle period of the message to be reminded which is consumed currently; and searching corresponding route information in the first database according to the route identification timing based on the delay pushing task.
Optionally, based on the delay pushing task, the step of searching the first database for the corresponding routing information according to the routing identifier timing includes: storing the delayed pushing task through a time wheel, so that the time wheel processes the stored delayed pushing task at fixed time; for the delay pushing task which is currently processed, searching corresponding route information in a first database according to the route identification timing; and/or, the message queue is Kafka.
Optionally, before generating the delayed push task according to the cycle period of the currently consumed cyclic push request, the method further includes: storing the message to be reminded to a second database according to the message identification of the message to be reminded corresponding to the received cyclic push request; the parameter information also comprises a message identifier of the message to be reminded; and for the current consumed message to be reminded, determining that the corresponding message to be reminded exists in the second database according to the message identification.
Optionally, the method further comprises: receiving a closing push request, and analyzing the closing push request to determine a message identifier of a corresponding circulating push request; searching a message to be reminded of a corresponding cyclic push request in the second database according to the message identifier; and deleting the searched message to be reminded of the corresponding circulating push request.
Optionally, the distributed service cluster is a Websocket service cluster; and/or, the first database is a Redis database.
In order to achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an apparatus for cyclically pushing a reminder message.
The device for circularly pushing the reminding message comprises the following steps:
the request receiving module is used for receiving the cyclic push request, analyzing the cyclic push request and determining parameter information of the cyclic push request, wherein the parameter information at least comprises a cyclic period, a route identifier and a message to be reminded;
the route determining module is used for searching corresponding route information in the first database at regular time according to the cycle period and the route identification; the first database is used for storing the route information of the front end when the front end establishes connection with a service node in the distributed service cluster;
and the message pushing module is used for calling the service node in the distributed service cluster according to the routing information, so that the service node pushes the message to be reminded to the corresponding front end.
Optionally, the route determining module is further configured to send a message to be reminded of the received cyclic push request to a message queue; consuming the message to be reminded in the message queue, and generating a delayed pushing task according to the cycle period of the message to be reminded which is consumed currently; and searching corresponding route information in the first database according to the route identification timing based on the delay pushing task.
Optionally, the route determining module is further configured to save the delayed push task through a time wheel, so that the time wheel processes the saved delayed push task at a fixed time; for the delay pushing task which is currently processed, searching corresponding route information in a first database according to the route identification timing; and/or, the message queue is Kafka.
Optionally, the route determining module is further configured to store the message to be reminded to the second database according to the message identifier of the message to be reminded corresponding to the received cyclic push request; the parameter information also comprises a message identifier of the message to be reminded; and for the current consumed message to be reminded, determining that the corresponding message to be reminded exists in the second database according to the message identification.
Optionally, the system further comprises a request closing module, which is used for receiving a closing push request, analyzing the closing push request and determining the message identifier of the corresponding circulating push request; searching a message to be reminded of a corresponding cyclic push request in the second database according to the message identifier; and deleting the searched message to be reminded of the corresponding circulating push request.
Optionally, the distributed service cluster is a Websocket service cluster; and/or, the first database is a Redis database.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an electronic apparatus.
The electronic equipment of the embodiment of the invention comprises: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the method for circularly pushing the reminding message.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided a computer readable medium having stored thereon a computer program, wherein the program when executed by a processor implements the method of cyclically pushing a reminder message of any one of the above.
One embodiment of the above invention has the following advantages or benefits: the method can directly determine the corresponding route information according to the analyzed parameter information of the circulating push request and push the message to be reminded in the parameter information to the front end according to the route information, so that the back end service does not need to define the query service. When the front end establishes connection with the service nodes in the distributed service cluster, the routing information of the front end is stored in the database, so that for the processed circular push request, the corresponding routing information can be searched in the database according to the routing identification in the parameter information of the circular push request, and the corresponding service nodes are further called according to the routing information so as to push the message to be reminded to the corresponding front end. And the message to be reminded is a message for determining the need of reminding, and the front end is not required to judge which needs to be reminded, how to remind and the like. The embodiment of the invention changes the push timing mode into the mode determined by the server, so that the push timing method can send the reminding message to the front end of any service and connection, a plurality of timers are not required to be defined at the front end, and an interface is not required to be specially defined for polling the front end.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a method of circularly pushing alert messages according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an architecture of a system for implementing a method for circularly pushing alert messages according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a front end establishing connection timing with a service node in a distributed service cluster according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a front end disconnect timing with a service node in a distributed service cluster according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a cyclic push alert message timing according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of the main modules of an apparatus for circulating push alert messages according to an embodiment of the present invention;
FIG. 7 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 8 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of main flow of a method for circularly pushing a reminder message according to an embodiment of the present invention, and as shown in fig. 1, the method for circularly pushing a reminder message according to an embodiment of the present invention mainly includes:
step S101: and receiving a cyclic push request, analyzing the cyclic push request to determine parameter information of the cyclic push request, wherein the parameter information at least comprises a cyclic period, a route identifier and a message to be reminded. After receiving the cyclic push request sent by the message pusher, the parameter information can be obtained by analyzing the cyclic push request, wherein the cyclic period in the parameter information is the period of the push reminding message, and the parameter information can also comprise a period time unit, but also adopts a default period time unit, such as minutes, 30 seconds and the like. The route identifier in the parameter information is used to uniquely identify the route information stored in the first database, for example, a unique ID (UUID) of the front end, a route field route used for performing route judgment when the message is pushed, and the like, or a combination of the UUID and the route. The message to be reminded in the parameter information refers to a message which needs to be circularly pushed to the front end. The message pusher includes the message to be reminded (message body) in the parameter information of the sent cyclic push request, and can directly save the message to be reminded to the Redis, for example, a message entity returned when pushing the message to the front end. The message to be reminded is a message which needs to be reminded, and the front end is not required to judge which needs to be reminded, how to remind and the like after receiving the pushed message.
Step S102: and according to the cycle period and the route identification, searching corresponding route information in the first database at regular time. The first database is used for storing the route information of the front end when the front end establishes connection with the service nodes in the distributed service cluster. Connection information (including routing information) is saved when a user connects to a service node in the distributed service cluster, and is logged off when the user logs off the browser and the service node disconnects. The connection information is stored in a Redis database, a Set aggregation structure is used, each UUID+route corresponds to one Set, node information of service nodes in the distributed service cluster connected by the current UUID and the route field is stored, and the node information comprises node IP and ports of the connected service nodes. Wherein, the liquid crystal display device comprises a liquid crystal display device,
rediskey is: WEB_SOCKET_SESSION_CACHE_ [ UUID ] [ ROUTE ],
each value in RedisSet is: [ node IP ]: [ Port ], e.g., 192.168.1.1:80
Specifically, a message to be reminded of the received cyclic push request is sent to a message queue. Consuming the message to be reminded in the message queue, and generating a delayed pushing task according to the cycle period of the message to be reminded which is consumed currently. Based on the delay pushing task, corresponding route information is searched in the first database according to the route identification timing.
Based on the delay pushing task, the step of searching the corresponding route information in the first database according to the route identification timing comprises the following steps: and storing the delayed push task through the time wheel, so that the time wheel processes the stored delayed push task at fixed time. And for the delay pushing task which is currently processed, searching corresponding route information in the first database according to the route identification timing.
The message queue is Kafka. Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all action flow data in consumer-scale websites. Has high performance, persistence, multi-copy backup and lateral expansion capability. The producer writes the information into the queue, and the consumer removes the information from the queue to perform business logic, thereby playing the roles of decoupling, peak clipping and asynchronous processing. The problem that the system pressure is difficult to deal with when the concurrency is increased in the prior art is further solved. And, for a large number of delay operations in Kafka, a timer (systemizer) for implementing the delay function can be customized based on the time wheel. The time wheel (TimingWheeel) in Kafka is a ring queue for storing timing tasks, the bottom layer is implemented by an array, and each element in the array can store a timing task list (TimerTaskList).
Before generating a delayed push task according to the cycle period of the currently consumed cyclic push request, storing the cyclic push request to a second database according to the received message identification of the cyclic push request. The parameter information also comprises a message identifier. And for the current consumed message to be reminded, determining that the corresponding message to be reminded exists in the second database according to the message identification. In the embodiment of the present invention, the first database and the second database may be the same database or may be different data. Further, the first database or the second database is a Redis database. And determining that a corresponding cyclic pushing request exists in the second database according to the message identification, wherein the fact that the service corresponding to the reminding message is not completed yet is indicated, and the reminding message still needs to be pushed continuously according to the cyclic period. If the service corresponding to the reminding message is finished, the cyclic push request stored in the second database can be deleted manually or automatically according to the closed push request.
For example, a circulation pushing reminding message is carried out on the business of the order A in-stock, the circulation period is 5, the message to be reminded is "order A in-stock", the default period time unit is hours, and then the "order A in-stock" is pushed to the user operation end every one hour within 5 hours from the current moment. But if the warehousing of order a has been completed within hour 3, the reminder message may be deleted from the second database. And when the next reminding after the service time point is finished, judging that the circulating push request corresponding to the service does not exist in the second database, and not continuing to carry out invalid reminding.
In the embodiment of the invention, the step of automatically deleting the cyclic push request stored in the second database according to the closed push request comprises the following steps: and receiving a closing push request, analyzing the closing push request and determining the message identification of the corresponding cyclic push request. Searching a corresponding circulating push request in the second database according to the message identification, and deleting the searched message to be reminded of the corresponding circulating push request. Through the process, the invalid reminding condition is avoided.
Step S103: and calling a service node in the distributed service cluster according to the routing information, so that the service node pushes the message to be reminded to the corresponding front end.
The distributed service cluster is a Websocket service cluster. The WebSocket makes data exchange between the client and the server simpler, and allows the server to actively push data to the client. In the WebSocket API, the browser and the server only need to complete one handshake, and can directly create persistent connection between the two and perform bidirectional data transmission. And websocket is a communication mode for establishing full duplex between the browser and the server, solves the problem of excessive resource consumption caused by http request-response, and provides a brand new implementation mode for the industry field with high real-time requirements.
According to the embodiment of the invention, the corresponding route information can be determined directly according to the analyzed parameter information of the cyclic push request, and the message to be reminded in the parameter information is pushed to the front end according to the route information, so that the back end service does not need to define the query service. When the front end establishes connection with the service nodes in the distributed service cluster, the routing information of the front end is stored in the database, so that for the processed circular push request, the corresponding routing information can be searched in the database according to the routing identification in the parameter information of the circular push request, and the corresponding service nodes are further called according to the routing information so as to push the message to be reminded to the corresponding front end. And the message to be reminded is a message for determining the need of reminding, and the front end is not required to judge which needs to be reminded, how to remind and the like. The embodiment of the invention changes the pushing timing mode into the mode determined by the server, so that the reminding message can be pushed to the front end of any service and connection, a plurality of timers are not required to be defined at the front end, and an interface is not required to be specially defined for polling the front end. The problem of the prior art that the server side is polled for multiple times to cause the increase of the pressure of the server side and the database is solved, and the development and the maintenance are convenient.
FIG. 2 is a schematic diagram of an architecture of a system for implementing a method for circularly pushing alert messages according to an embodiment of the present invention; FIG. 3 is a schematic diagram of a front end establishing connection timing with a service node in a distributed service cluster according to an embodiment of the present invention; FIG. 4 is a schematic diagram of a front end disconnect timing with a service node in a distributed service cluster according to an embodiment of the present invention; fig. 5 is a schematic diagram of a cyclic push alert message timing according to an embodiment of the present invention.
The embodiment of the invention can independently deploy the message pushing service, avoids the influence on the production environment and is convenient to expand. As shown in fig. 2, a system for implementing a method for circularly pushing a reminder message according to an embodiment of the present invention mainly includes: websocket cluster service, websocket session registration service, message push routing service, and cyclical message push service. The Websocket cluster service is used for carrying out Websocket communication with the browser side. The websocket session registration service is used for registering session information currently connected to the websocket cluster, and includes UUID, routing field, connection information, etc. The message routing service is used to send message alerts to the corresponding browser via the routing field. And the circulating message pushing service stores the message under the condition of receiving the request of back-end message pushing, and calls the message pushing routing service to search the connection information of websocket and the like.
And, the implementation of WebSocket cluster service is based on WebSocket cluster, which contains a plurality of nodes providing services, such as node one and node two shown in fig. 2, each of which contains a WebSocket service (WS service) HTTP service and a component of WebSocket session that remains connected to the current node. The WebSocket service is mainly used for communicating with a working end browser. The HTTP service is used for providing a message push routing service to call a reminder message to the service of the current node. In the embodiment of the invention, the Nginx is used for carrying out load balancing on a plurality of nodes, and when the browser is connected with the nodes in the WebSocket cluster service, the browser is connected with the Nginx service through the domain name and then loaded to the corresponding nodes by the Nginx. The WebSocket cluster connection URL (uniform resource locator) is as follows: ws/(domain name/ws/{ uuid }/{ route }. UUID: a unique ID of the currently connected client; route: and the routing field is used for carrying out routing judgment when the message is pushed.
The WebSocket session registration service is mainly used for storing the connection information of the browser and the nodes in the WebSocket cluster service, wherein the connection information comprises the IP and ports of the servers of the specific nodes in the WebSocket cluster connected to the browser and is used for routing subsequent messages to the specific servers. When a user connects to the cluster, the connection information is saved. When the user exits the browser and the cluster connection is disconnected, the connection information is logged out. As shown in fig. 3 and 4, when the front-end browser connects to a service node in the WebSocket cluster, the service node invokes WebSocket Session a registration service to save the connection information to the Redis database. When the browser and the service node in the WebSocket cluster are disconnected, the service node calls WebSocket Session registration service to delete the connection information from the Redis.
In the embodiment of the invention, the connection information is stored in the Redis, and a Set aggregation structure can be used, each UUID+route corresponds to one aggregation, and node information connected to the cluster through the current UUID and the routing field is stored.
Rediskey is: WEB_SOCKET_SESSION_CACHE_ [ UUID ] [ ROUTE ]
Each value in RedisSet is: [ node IP ]: [ Port ], e.g., 192.168.1.1:80
The message pushing route service is mainly used for connecting the WebSocket cluster service and the circulating message pushing service. When the message pushing route service calls the route pushing message, the service of inquiring the registration address provided by the WebSocket session registration service inquires all corresponding registered WebSocket node addresses, then traverses the node address set, calls the HTTP service provided by the node to push the reminder to the corresponding node, and calls the WebSocket session pushing message stored by the current node to the browser after receiving the pushing request.
The cyclic message pushing service mainly comprises the following steps: the system comprises six parts, namely an external interface, a Kafka message sending component, message information storage, kafka message consumption, a time wheel and a time delay message processor. The external interface provides an RPC interface and an HTTP interface of two protocols, and each interface can receive a circular push request and close the circular push request. The support of various external interfaces is provided, so that the direct electrophoresis of various interfaces can be facilitated. The entry of the circular push request is shown in the following table:
Fields Type(s) Description of the invention
uuid String UUID corresponds to UUID when browser is connected
route String The routing field corresponds to the route when the browser is connected
messageId String Unique ID of message
message String Message
cyclePeriod Long Cycle period
cycleTimeUnit TimeUnit Cycle time units, defaults to minutes
The Kafka messaging component is configured to send a recurring push request to Kafka, which is configured to decouple the message push request from the push component, and Kafka topic is: wsp-cycle-message. Kafka is a high throughput distributed publish-subscribe messaging system that can handle all action flow data in consumer scale websites. And storing information of the message, wherein the message can be stored in Redis, and each UUID+route corresponds to one map by using a Hash structure.
Rediskey is: cyclic_MESSAGE_ [ UUID ] [ ROUTE ]
The keys in Redismap are: the messageId, value is: the message is pushed into the JSON string of the argument.
Consuming the Kafka message is used to consume the message in Kafka. The time wheel is used for storing the delayed push message, and the time wheel service needs to be started when the cyclic message push service is started. The delay message processor is used for calling to route the push message to the corresponding node. Redis can also store Session information and reminding information to be pushed.
As shown in fig. 5, the message pusher invokes the outbound interface, sending a circular push request. And calling the cyclic message pushing service through the pair of external interfaces, so that the cyclic message pushing service pushes messages to the Kafka. For a high throughput scenario, there may be a continuous message pusher invoking sending a circular push request to the external interface, so the circular message push service may continuously push the received reminder message to Kafka. And the cyclic message pushing service saves the received cyclic pushing request to Redis. After the circulation message pushing service receives the circulation pushing request, the message to be reminded can be stored to the Redis according to the route identification and the message identification.
In the process of consuming Kafka information, firstly, inquiring information in Redis according to the information identification, judging whether the corresponding information to be reminded exists in the Redis, and if the information to be reminded does not exist, indicating that the corresponding service is usual, and no invalid reminding is needed. If so, a deferred message push task is added to the time wheel.
The time wheel triggers a delayed message push server that invokes a message push routing service. Then, the message pushing route service searches route information according to the route identification, and queries a service node registered by a browser to be pushed according to the route information. Further, the HTTP interface provided by the WebSocket cluster node is called to push the message to the corresponding node, and finally the WebSocket cluster node pushes the message to the corresponding browser. And pushing the completed reminding message to the Kafka by the message pushing routing service.
Based on the embodiment of the invention, the back-end service is queried regularly in a mode of not carrying out ajax polling after the WebSocket protocol is used for connection. In addition, the pushing timing mode is changed into the timing mode by the service end, and a plurality of timers are not required to be defined at the front end. And the service code does not need to specially define an interface to poll the front end, and only needs to call the interface provided by the push service at the place where the push message is expected. The circulation pushing reminding message is realized through websocket and time wheel ring structure. And, the directed pushing of the reminding message in the distributed environment is realized by combining a message queue (kafka), a route and a Redis.
Fig. 6 is a schematic diagram of main modules of an apparatus for circularly pushing a reminder message according to an embodiment of the present invention, and as shown in fig. 6, an apparatus 600 for circularly pushing a reminder message according to an embodiment of the present invention includes a request receiving module 601, a route determining module 602, and a message pushing module 603.
The request receiving module 601 is configured to receive a cyclic push request, parse the cyclic push request, and determine parameter information of the cyclic push request, where the parameter information at least includes a cyclic period, a route identifier, and a message to be reminded.
The route determining module 602 is configured to search the first database for corresponding route information periodically according to the cycle period and the route identifier. The first database is used for storing the route information of the front end when the front end establishes connection with the service nodes in the distributed service cluster. The route determining module is also used for sending the message to be reminded of the received cyclic push request to the message queue; consuming the message to be reminded in the message queue, and generating a delayed pushing task according to the cycle period of the message to be reminded which is consumed currently. And searching corresponding route information in the first database according to the route identification timing based on the delay pushing task.
The route determining module is also used for storing the delay pushing task through the time wheel, so that the time wheel processes the stored delay pushing task at fixed time; and for the delay pushing task which is currently processed, searching corresponding route information in the first database according to the route identification timing. The message queue may be Kafka.
The route determining module is further configured to store the cyclic push request to the second database according to the received message identifier of the cyclic push request before generating the delayed push task according to the cyclic period of the currently consumed cyclic push request. The parameter information also comprises a message identifier. And for the current consumed message to be reminded, determining that the corresponding message to be reminded exists in the second database according to the message identification.
The device for circularly pushing the reminding message also comprises a request closing module, wherein the request closing module is used for receiving the closing pushing request and analyzing the closing pushing request to determine the message identification of the corresponding circularly pushing request. Searching a corresponding circulating push request in a second database according to the message identifier; and deleting the searched message to be reminded of the corresponding circulating push request.
The message pushing module 603 is configured to invoke a service node in the distributed service cluster according to the routing information, so that the service node pushes the message to be reminded to the corresponding front end.
The distributed service cluster is a Websocket service cluster. The first database is a Redis database. In the embodiment of the present invention, the first database and the second database may be the same database, and may be both Redis databases.
According to the embodiment of the invention, the route determining module can directly determine the corresponding route information according to the parameter information of the cyclic push request analyzed by the request receiving module, and the message pushing module pushes the message to be reminded in the parameter information to the front end according to the route information, so that the back end service does not need to define the query service. When the front end establishes connection with the service nodes in the distributed service cluster, the routing information is stored in the database, so that for the processed circular push request, the routing determination module can find the corresponding routing information in the database according to the routing identification in the parameter information. Further, the message pushing module calls a corresponding service node according to the routing information so as to push the message to be reminded to the corresponding front end. And the message to be reminded is a message for determining the need of reminding, and the front end is not required to judge which needs to be reminded, how to remind and the like. The embodiment of the invention changes the pushing timing mode into the mode determined by the server, so that the reminding message can be pushed to the front end of any service and connection, a plurality of timers are not required to be defined at the front end, and an interface is not required to be specially defined for polling the front end. The problem of the prior art that the server side is polled for multiple times to cause the increase of the pressure of the server side and the database is solved, and the development and the maintenance are convenient.
Fig. 7 illustrates an exemplary system architecture 700 of a method of cycling push alert messages or an apparatus of cycling push alert messages to which embodiments of the present invention may be applied.
As shown in fig. 7, a system architecture 700 may include terminal devices 701, 702, 703, a network 704, and a server 705. The network 704 is the medium used to provide communication links between the terminal devices 701, 702, 703 and the server 705. The network 704 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 705 via the network 704 using the terminal devices 701, 702, 703 to receive or send messages or the like. Various communication client applications such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only) may be installed on the terminal devices 701, 702, 703.
The terminal devices 701, 702, 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 705 may be a server providing various services, such as a background management server (by way of example only) providing support for shopping-type websites browsed by users using the terminal devices 701, 702, 703. The background management server can analyze and other data of the received product information inquiry request and feed back the processing result to the terminal equipment.
It should be noted that, the method for circularly pushing the reminding message provided by the embodiment of the present invention is generally executed by the server 705, and accordingly, the device for circularly pushing the reminding message is generally set in the server 705.
It should be understood that the number of terminal devices, networks and servers in fig. 7 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 8, there is illustrated a schematic diagram of a computer system 800 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 8 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 8, the computer system 800 includes a Central Processing Unit (CPU) 801 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, mouse, etc.; an output portion 807 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage section 808 including a hard disk or the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. The drive 810 is also connected to the I/O interface 805 as needed. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as needed so that a computer program read out therefrom is mounted into the storage section 808 as needed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication section 809, and/or installed from the removable media 811. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 801.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor includes a request receiving module, a route determining module, and a message pushing module. The names of these modules do not in some cases limit the module itself, for example, the request receiving module may also be described as "a module that receives a cyclic push request, parses the cyclic push request, and determines its parameter information".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: receiving a cyclic push request, analyzing the cyclic push request to determine parameter information of the cyclic push request, wherein the parameter information at least comprises a cyclic period, a route identifier and a message to be reminded; according to the cycle period and the route identification, corresponding route information is searched in the first database at regular time; the first database is used for storing the route information of the front end when the front end establishes connection with a service node in the distributed service cluster; and calling a service node in the distributed service cluster according to the routing information, so that the service node pushes the message to be reminded to the corresponding front end.
According to the embodiment of the invention, the corresponding route information can be determined directly according to the analyzed parameter information of the cyclic push request, and the message to be reminded in the parameter information is pushed to the front end according to the route information, so that the back end service does not need to define the query service. When the front end establishes connection with the service nodes in the distributed service cluster, the routing information of the front end is stored in the database, so that for the processed circular push request, the corresponding routing information can be searched in the database according to the routing identification in the parameter information of the circular push request, and the corresponding service nodes are further called according to the routing information so as to push the message to be reminded to the corresponding front end. And the message to be reminded is a message for determining the need of reminding, and the front end is not required to judge which needs to be reminded, how to remind and the like. The embodiment of the invention changes the pushing timing mode into the mode determined by the server, so that the reminding message can be pushed to the front end of any service and connection, a plurality of timers do not need to be defined at the front end, an interface does not need to be specially defined for polling the front end, and the front end does not need to judge which reminding is needed, how to remind and the like. The problem of the prior art that the server side is polled for multiple times to cause the increase of the pressure of the server side and the database is solved, and the development and the maintenance are convenient.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method for cyclically pushing a reminder message, comprising:
receiving a cyclic push request, analyzing the cyclic push request to determine parameter information of the cyclic push request, wherein the parameter information at least comprises a cyclic period, a route identifier and a message to be reminded;
according to the cycle period and the route identification, searching corresponding route information in a first database at regular time; the first database is used for storing the route information of the front end when the front end establishes connection with a service node in the distributed service cluster;
calling a service node in the distributed service cluster according to the routing information, so that the service node pushes the message to be reminded to the corresponding front end;
the step of searching the corresponding route information in the first database regularly according to the cycle period and the route identification comprises the following steps:
Sending the message to be reminded of the received cyclic push request to a message queue;
consuming the message to be reminded in the message queue, and generating a delayed pushing task according to the cycle period of the message to be reminded which is consumed currently;
based on the delay pushing task, searching corresponding route information in a first database according to route identification timing;
the step of searching the corresponding route information in the first database according to the route identification timing based on the delay pushing task comprises the following steps: storing the delayed pushing task through a time wheel, so that the time wheel processes the stored delayed pushing task at fixed time; for the delay pushing task which is currently processed, searching corresponding route information in a first database according to the route identification timing; the message queue is Kafka, a large number of delay operations exist in the Kafka, and a timer for realizing a delay function is customized based on a time wheel.
2. The method of claim 1, further comprising, prior to generating the deferred push task based on a cycle period of a currently consumed recurring push request:
storing the message to be reminded to a second database according to the message identification of the message to be reminded corresponding to the received cyclic push request; the parameter information also comprises a message identifier of the message to be reminded;
And for the current consumed message to be reminded, determining that the corresponding message to be reminded exists in the second database according to the message identification.
3. The method as recited in claim 2, further comprising:
receiving a closing push request, and analyzing the closing push request to determine a message identifier of a corresponding circulating push request;
searching a message to be reminded of a corresponding cyclic push request in the second database according to the message identifier;
and deleting the searched message to be reminded of the corresponding circulating push request.
4. The method of claim 1, wherein the distributed service cluster is a Websocket service cluster; and/or
The first database is a Redis database.
5. An apparatus for cyclically pushing a reminder message, comprising:
the request receiving module is used for receiving the cyclic push request, analyzing the cyclic push request and determining parameter information of the cyclic push request, wherein the parameter information at least comprises a cyclic period, a route identifier and a message to be reminded;
the route determining module is used for searching corresponding route information in the first database at regular time according to the cycle period and the route identification; the first database is used for storing the route information of the front end when the front end establishes connection with a service node in the distributed service cluster;
The message pushing module is used for calling the service node in the distributed service cluster according to the routing information, so that the service node pushes the message to be reminded to the corresponding front end;
the route determining module is also used for sending the message to be reminded of the received cyclic push request to the message queue; consuming the message to be reminded in the message queue, and generating a delayed pushing task according to the cycle period of the message to be reminded which is consumed currently; based on the delay pushing task, searching corresponding route information in a first database according to route identification timing;
the route determining module is further used for storing the delay pushing task through a time wheel, so that the time wheel processes the stored delay pushing task at fixed time; for the delay pushing task which is currently processed, searching corresponding route information in a first database according to the route identification timing; the message queue is Kafka, a large number of delay operations exist in the Kafka, and a timer for realizing a delay function is customized based on a time wheel.
6. The apparatus of claim 5, wherein the route determining module is further configured to store the message to be reminded to the second database according to a message identifier of the message to be reminded corresponding to the received cyclic push request; the parameter information also comprises a message identifier of the message to be reminded; and for the current consumed message to be reminded, determining that the corresponding message to be reminded exists in the second database according to the message identification.
7. The apparatus of claim 6, further comprising a request closing module configured to receive a closing push request, parse the closing push request, and determine a message identifier of a corresponding cyclic push request; searching a message to be reminded of a corresponding cyclic push request in the second database according to the message identifier; and deleting the searched message to be reminded of the corresponding circulating push request.
8. The apparatus of claim 5, wherein the distributed service cluster is a Websocket service cluster; and/or
The first database is a Redis database.
9. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-4.
10. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-4.
CN201910378895.5A 2019-05-08 2019-05-08 Method and device for circularly pushing reminding message Active CN111917687B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910378895.5A CN111917687B (en) 2019-05-08 2019-05-08 Method and device for circularly pushing reminding message

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910378895.5A CN111917687B (en) 2019-05-08 2019-05-08 Method and device for circularly pushing reminding message

Publications (2)

Publication Number Publication Date
CN111917687A CN111917687A (en) 2020-11-10
CN111917687B true CN111917687B (en) 2023-06-27

Family

ID=73241975

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910378895.5A Active CN111917687B (en) 2019-05-08 2019-05-08 Method and device for circularly pushing reminding message

Country Status (1)

Country Link
CN (1) CN111917687B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112491696A (en) * 2020-11-30 2021-03-12 上海昌投网络科技有限公司 Message center system based on message pushing
CN112671560B (en) * 2020-12-11 2023-08-01 广东电力通信科技有限公司 High-availability distributed real-time alarm processing method and system
CN112910987A (en) * 2021-01-28 2021-06-04 长沙市到家悠享网络科技有限公司 Message pushing method, system, device, equipment and storage medium
CN113452774B (en) * 2021-06-25 2022-07-12 睿视(苏州)视频科技有限公司 Message pushing method, device, equipment and storage medium
CN114039961A (en) * 2021-10-08 2022-02-11 中移(杭州)信息技术有限公司 Message pushing method, device, server and storage medium based on WebSocket
CN114172882B (en) * 2021-11-19 2024-04-12 武汉紫阑信息技术有限公司 Webpage end message reminding method, device, equipment and storage medium
CN115049085A (en) * 2022-06-07 2022-09-13 中国银行股份有限公司 Method and device for reminding reservation service of bank outlets

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011124132A1 (en) * 2010-04-07 2011-10-13 中兴通讯股份有限公司 Data communications system and method
CN104184663A (en) * 2014-07-17 2014-12-03 北京交通大学 Communication method and device based on software-defined network and integrated identification network
CN104468805A (en) * 2014-12-12 2015-03-25 用友软件股份有限公司 Message routing device and method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050108417A1 (en) * 2003-11-19 2005-05-19 Serge Haumont System and method for reducing subscriber database loads
US8594679B2 (en) * 2008-03-07 2013-11-26 Tekelec Global, Inc. Methods, systems, and computer readable media for routing a message service message through a communications network
CN102014043B (en) * 2009-09-08 2013-12-04 中兴通讯股份有限公司 Address mapping system, data transmission method and address mapping maintenance method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011124132A1 (en) * 2010-04-07 2011-10-13 中兴通讯股份有限公司 Data communications system and method
CN104184663A (en) * 2014-07-17 2014-12-03 北京交通大学 Communication method and device based on software-defined network and integrated identification network
CN104468805A (en) * 2014-12-12 2015-03-25 用友软件股份有限公司 Message routing device and method

Also Published As

Publication number Publication date
CN111917687A (en) 2020-11-10

Similar Documents

Publication Publication Date Title
CN111917687B (en) Method and device for circularly pushing reminding message
CN108696374B (en) Method and device for updating client configuration
CN110581890B (en) Routing method and device for service request
CN108897854B (en) Monitoring method and device for overtime task
US7761522B2 (en) System and method for providing asynchronous notifications using synchronous data sources
CN112860451A (en) Multi-tenant data processing method and device based on SaaS
CN108377247B (en) Message pushing method and device
CN112445868B (en) Service message processing method and device
CN110851468A (en) Method and device for making simulation response to test request of client
WO2015172497A1 (en) Message pushing and acquisition methods and devices, and computer readable storage medium
CN110737676A (en) Data query method and device
CN112653614A (en) Request processing method and device based on message middleware
CN113342686A (en) Test data generation method and device
CN110798495B (en) Method and server for end-to-end message push in cluster architecture mode
CN112838935A (en) Electronic data exchange method and system
CN112084042A (en) Message processing method and device
CN113190558A (en) Data processing method and system
CN113765774A (en) Message real-time synchronization method and device, electronic equipment and medium
CN112948138A (en) Method and device for processing message
CN115629909A (en) Service data processing method and device, electronic equipment and storage medium
CN113783826B (en) Micro-service exception handling method and device
CN112688982B (en) User request processing method and device
CN112749204B (en) Method and device for reading data
CN113138943B (en) Method and device for processing request
CN113760929A (en) Data synchronization method and device, electronic equipment and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant