技术领域Technical field
本发明属于服务端推送消息技术领域,尤其涉及一种集群模式下实现服务器推送消息机制的方法及系统。The invention belongs to the technical field of server push messages, and in particular relates to a method and system for implementing a server push message mechanism in cluster mode.
背景技术Background technique
本部分的陈述仅仅是提供了与本公开相关的背景技术信息,不必然构成在先技术。The statements in this section merely provide background technical information related to the present disclosure and do not necessarily constitute prior art.
Web应用中,客户端如浏览器在需要即时取得后台最新数据展示给用户时,通常采用轮询的方式,这样的轮询请求多数情况下是无效的(可能后台数据没有发生变化)且即时性比较弱,对前后台的压力也比较大。In web applications, clients such as browsers usually use polling when they need to obtain the latest background data immediately and display it to the user. Such polling requests are invalid in most cases (the background data may not have changed) and are immediacy. It is relatively weak and puts more pressure on the front and backstage.
现有技术中,无论后台数据发生变化与否,轮询是一直从后台取数据的,比如每5秒钟取一次,当5秒内后台数据发生了变化,则由于需要等待5秒不能即时展示,只能5秒后轮询处理取到数据后展示。另外,如果1分钟内后台的数据没有变化轮询也是要执行12次的,只是12次取的数据都是一样,所以这12次取的数据是无效的。In the existing technology, no matter whether the background data changes or not, polling always fetches data from the background, for example, once every 5 seconds. When the background data changes within 5 seconds, it cannot be displayed immediately because it needs to wait for 5 seconds. , it can only be displayed after polling and processing in 5 seconds to obtain the data. In addition, if the data in the background does not change within 1 minute, polling will also be performed 12 times, but the data fetched 12 times are the same, so the data fetched 12 times is invalid.
随着信息化社会的不断发展,及时准确的获得信息对于人们的正确决策有着非常重要的作用,也对各类技术提出了新的要求。With the continuous development of the information society, timely and accurate acquisition of information plays a very important role in people's correct decision-making, and also puts forward new requirements for various technologies.
发明内容Contents of the invention
为克服上述现有技术的不足,本发明提供了一种集群模式下实现服务器推送消息机制的方法,不仅可以实现集群节点间的通讯,而且可以满足集群环境下服务器主动推送消息到客户端,满足即时性要求,减少因轮询对前后台造成的压力。In order to overcome the shortcomings of the above-mentioned prior art, the present invention provides a method for implementing a server push message mechanism in a cluster mode, which not only can realize communication between cluster nodes, but also can satisfy the requirements of the server actively pushing messages to the client in a cluster environment. Immediate requirements reduce the pressure on the front and backend caused by polling.
为实现上述目的,本发明的一个或多个实施例提供了如下技术方案:To achieve the above objectives, one or more embodiments of the present invention provide the following technical solutions:
一种集群环境下自动提醒处理工作的方法,包括:A method for automatically reminding processing work in a cluster environment, including:
通过客户端浏览器登录web应用系统,并使用长期保持的http连接实现客户端和服务器间的基于事件驱动的通信;Log in to the web application system through the client browser, and use long-term http connections to implement event-driven communication between the client and the server;
客户端通过加入需要订阅的各种主题消息类型把信息请求发送至服务端,客户端浏览器接收服务器端主动发送的数据后进行展示。The client sends information requests to the server by adding various topic message types that need to be subscribed. The client browser receives the data actively sent by the server and displays it.
进一步的技术方案,客户端登录应用系统,项目启动后加载activemq配置项,在spring中生成两种消息目的地用于发送消息时推送消息到activemq,一个是队列目的地,一个是主题目的地;同时加载对消息中间件中的队列和主题进行监听的监听器,在有新消息时即时接收处理消息。Further technical solution is that the client logs in to the application system, loads the activemq configuration items after the project is started, and generates two message destinations in spring for pushing messages to activemq when sending messages, one is the queue destination and the other is the topic destination; At the same time, load the listener for monitoring the queue and topic in the message middleware, and receive and process the message immediately when there is a new message.
进一步的技术方案,服务器端产生需要推送的数据后,解析数据获取接收对象推送指定的客户端,设置目的地和消息体通过公用方法推送给activemq,activemq在收到消息后会将数据存放到表中等待监听者读取。A further technical solution is that after the server generates the data that needs to be pushed, it parses the data to obtain the receiving object and pushes it to the specified client, sets the destination and message body and pushes it to activemq through public methods. After receiving the message, activemq will store the data in the table. Waiting for the listener to read.
进一步的技术方案,客户端监听者发现有待处理的消息后,从activemq中读取消息,activemq自动根据消息类型是队列还是主题决定是否清空消息。A further technical solution is that after the client listener discovers a message to be processed, it reads the message from activemq, and activemq automatically decides whether to clear the message based on whether the message type is a queue or a topic.
进一步的技术方案,监听者获取消息后,解析消息体获取消息内容和接收者信息,通过pushlet获取在线用户列表并找出其中的消息接收者将消息即时推送到客户端浏览器,若客户端浏览器对应的用户不在线,则将消息持久化到数据库,上线后查找待处理消息并展示给用户。A further technical solution is that after the listener obtains the message, it parses the message body to obtain the message content and recipient information, obtains the online user list through pushlet and finds the message recipients, and then pushes the message to the client browser immediately. If the client browses If the user corresponding to the server is not online, the message will be persisted to the database. After going online, the pending message will be searched and displayed to the user.
进一步的技术方案,客户端有待处理的消息后,通过点击消息处理后系统将消息设置为已读状态,再次登录后不再展示已读消息。A further technical solution is that after the client has a message to be processed, the system will set the message to read status by clicking on the message processing, and the read message will no longer be displayed after logging in again.
进一步的技术方案,客户端退出系统取消订阅,注销会话,不再接受消息。As a further technical solution, the client exits the system to unsubscribe, logs out of the session, and no longer accepts messages.
一种集群环境下自动提醒处理工作的系统,包括:客户端及服务端;A system for automatically reminding processing work in a cluster environment, including: client and server;
通过客户端登录系统,并使用长期保持的http连接实现客户端和服务器间的基于事件驱动的通信;Log in to the system through the client and use long-term http connections to implement event-driven communication between the client and the server;
服务器端接收客户端用户根据需要加入的订阅请求,实现push数据到指定客户端浏览器后进行展示。The server receives the subscription request from the client user as needed, and pushes the data to the specified client browser for display.
以上一个或多个技术方案存在以下有益效果:One or more of the above technical solutions have the following beneficial effects:
客户端用户免于安装任何软件,只要有浏览器即可:Pushlet是一种comet架构的实现的基于Servlet机制,数据从server端的Java对象直接推送(push)到客户端浏览器的(动态)HTML页面,而无需任何Java applet或者插件,用户免于安装任何软件。Client users do not need to install any software, as long as they have a browser: Pushlet is a Servlet-based mechanism implemented in the comet architecture. Data is directly pushed (push) from the Java object on the server side to the (dynamic) HTML of the client browser. page without any Java applets or plug-ins, and users do not need to install any software.
客户端展示效果的多样式。消息在浏览器上的展示与javascript无缝对接,接收和展示消息完全使用js和html元素组成,浏览器接收消息后可以根据需要组成多种多样的展示效果。Multiple styles of client display effects. The display of messages on the browser is seamlessly connected with JavaScript. Receiving and displaying messages is completely composed of js and html elements. After the browser receives the message, it can form a variety of display effects as needed.
满足即时性要求。pushlet消息的发送使用http协议,在网络状态良好的情况下,在线用户几乎察觉不到数据流转过程消耗的时间。Activemq的时效性也是毫秒级的,从发送消息到接收消息的时间几乎可以忽略不计。Meet immediacy requirements. Pushlet messages are sent using the http protocol. When the network status is good, online users are almost unaware of the time consumed by the data transfer process. Activemq's timeliness is also on the millisecond level, and the time from sending a message to receiving it is almost negligible.
提高消息的有效性。普通轮询方式多数情况下获取的消息数据都是无效的。本专利在发送消息给用户时因基于确切的需求即有新的数据产生或者变化时触发,从而确保数据百分之百的有效性。Improve message effectiveness. In most cases, the message data obtained by the ordinary polling method is invalid. This patent is triggered when new data is generated or changed based on exact needs when sending messages to users, thereby ensuring 100% validity of the data.
本申请的技术方案可以解决背景技术中所存在的轮询间隙内不能取到最新数据的问题,只要有数据变化可以即时推送展示,不需要等待。The technical solution of this application can solve the problem in the background technology that the latest data cannot be obtained within the polling gap. As long as there is a change in the data, it can be pushed and displayed immediately without waiting.
附图说明Description of drawings
构成本发明的一部分的说明书附图用来提供对本发明的进一步理解,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。The description and drawings that constitute a part of the present invention are used to provide a further understanding of the present invention. The illustrative embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention.
图1为本发明实施例用户登录系统示意图;Figure 1 is a schematic diagram of a user login system according to an embodiment of the present invention;
图2为本发明实施例启动加载示意图;Figure 2 is a schematic diagram of startup loading according to an embodiment of the present invention;
图3为本发明实施例消息推送示意图。Figure 3 is a schematic diagram of message push according to an embodiment of the present invention.
具体实施方式Detailed ways
应该指出,以下详细说明都是示例性的,旨在对本发明提供进一步的说明。除非另有指明,本文使用的所有技术和科学术语具有与本发明所属技术领域的普通技术人员通常理解的相同含义。It should be noted that the following detailed description is exemplary and is intended to provide further explanation of the present invention. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
需要注意的是,这里所使用的术语仅是为了描述具体实施方式,而非意图限制根据本发明的示例性实施方式。如在这里所使用的,除非上下文另外明确指出,否则单数形式也意图包括复数形式,此外,还应当理解的是,当在本说明书中使用术语“包含”和/或“包括”时,其指明存在特征、步骤、操作、器件、组件和/或它们的组合。It should be noted that the terms used herein are for the purpose of describing specific embodiments only, and are not intended to limit the exemplary embodiments according to the present invention. As used herein, the singular forms are also intended to include the plural forms unless the context clearly indicates otherwise. Furthermore, it will be understood that when the terms "comprises" and/or "includes" are used in this specification, they indicate There are features, steps, operations, means, components and/or combinations thereof.
在不冲突的情况下,本发明中的实施例及实施例中的特征可以相互组合。The embodiments and features of the embodiments of the present invention may be combined with each other without conflict.
实施例一Embodiment 1
本实施例公开了一种集群环境下自动提醒处理工作的方法,不仅可以实现集群服务节点间的通讯,而且可以满足集群环境下服务器主动推送消息到客户端,满足即时性要求的同时,减少因轮询对前后台造成的压力。This embodiment discloses a method for automatic reminder processing in a cluster environment, which can not only realize communication between cluster service nodes, but also enable the server to proactively push messages to the client in a cluster environment, meeting the requirements of immediacy while reducing the cost of The pressure polling puts on the front and backend.
具体实施例子中,参见附图1所述,用户登陆应用系统,利用jsp/servlet技术,使用长期保持的http连接实现客户端和服务器间的基于事件驱动的通信。通过在cookie中加入唯一TOKEN来标识用户,用户在客户端通过TOKEN身份加入pushlet并监听各类主题消息。后台服务定义多种类型的主题消息类型,用户根据需要加入订阅不同类型的主题用于接收不类型的消息,服务端根据TOKEN向指定客户端发送消息,客户端监听到新消息时可以即时展示。In the specific implementation example, as shown in Figure 1, the user logs in to the application system, uses jsp/servlet technology, and uses long-term http connections to implement event-driven communication between the client and the server. The user is identified by adding a unique TOKEN to the cookie. The user joins the pushlet through the TOKEN identity on the client and monitors various topic messages. The background service defines multiple types of topic message types. Users can subscribe to different types of topics as needed to receive different types of messages. The server sends messages to the designated client based on the TOKEN. When the client hears new messages, they can be displayed immediately.
参见附图2所示,后台服务端启动后会加载activemq配置项用于在spring中生成两种消息目的地用于发送消息时推送消息到activemq,一个是队列目的地只能一人收到消息,一个是主题目的地多人可以收到消息;同时加载对消息中间件中的队列和主题进行监听的监听器,在有新消息时可以即时接收处理消息。As shown in Figure 2, after the background server is started, the activemq configuration item will be loaded to generate two message destinations in spring for pushing messages to activemq when sending messages. One is that only one person can receive the message at the queue destination. One is that multiple people at the topic destination can receive messages; at the same time, a listener for monitoring the queue and topic in the message middleware is loaded, so that when there is a new message, the message can be received and processed immediately.
后台产生需要推送的数据后,根据需要推送的人员找到对应的TOKEN,以json格式设置目的地、消息体和接收人,通过公用方法推送给activemq,activemq在收到消息后解析数据,将数据存放到表中等待后台集群节点中的监听者读取。After the data that needs to be pushed is generated in the background, the corresponding TOKEN is found according to the person who needs to push, the destination, message body and recipient are set in json format, and pushed to activemq through public methods. Activemq parses the data after receiving the message and stores the data. Go to the table and wait for the listener in the background cluster node to read.
参见附图3所示,监听者发现有待处理的消息后,从activemq中读取消息,activemq自动根据消息类型是队列还是主题决定是否清空消息。监听者获取消息后,解析消息体获取消息内容和接收者信息,通过TOKEN获取在线用户列表并找出其中的消息接收者将消息即时推送到用户,若在pushlet监听中没有找到用户即用户不在线,则将消息持久化到数据库,用户上线后查找待处理消息并展示给用户。As shown in Figure 3, after the listener discovers that there is a message to be processed, it reads the message from activemq. Activemq automatically decides whether to clear the message based on whether the message type is a queue or a topic. After the listener obtains the message, it parses the message body to obtain the message content and recipient information, obtains the online user list through TOKEN, finds out the message recipients, and pushes the message to the user immediately. If the user is not found in the pushlet listening, the user is not online. , the message will be persisted to the database. After the user goes online, the pending message will be found and displayed to the user.
用户发现有待处理的消息后,点击消息处理后系统将消息设置为已读状态,再次登录后不再展示已读消息。After the user discovers that there is a message to be processed, the system sets the message to read status after clicking on the message processing, and the read message will no longer be displayed after logging in again.
用户退出系统取消订阅,注销会话,不再接受消息。The user exits the system to unsubscribe, logs out of the session, and no longer accepts messages.
实施例二Embodiment 2
本实施例的目的是提供一种集群环境下自动提醒处理工作的系统,包括:客户端及服务端;The purpose of this embodiment is to provide a system for automatically reminding processing work in a cluster environment, including: a client and a server;
通过客户端登录系统,并使用长期保持的http连接实现客户端和服务器间的基于事件驱动的通信;Log in to the system through the client and use long-term http connections to implement event-driven communication between the client and the server;
服务器端接收客户端用户根据需要加入订阅,实现push数据到指定客户端浏览器后进行展示。The server receives client users to join subscriptions as needed, and pushes the data to the specified client browser for display.
服务器端产生需要推送的数据后,根据接收的需要推送的客户端,设置目的地和消息体通过公用方法推送给activemq,activemq在收到消息后会将数据存放到表中等待监听者读取。After the server generates the data that needs to be pushed, it sets the destination and message body and pushes it to activemq through public methods according to the client that needs to be pushed. After receiving the message, activemq will store the data in the table and wait for the listener to read it.
客户端监听者发现有待处理的消息后,从activemq中读取消息,activemq自动根据消息类型是队列还是主题决定是否清空消息;After the client listener discovers that there is a message to be processed, it reads the message from activemq. Activemq automatically decides whether to clear the message based on whether the message type is a queue or a topic;
监听者获取消息后,解析消息体获取消息内容和接收者信息,通过pushlet获取在线用户列表并找出其中的消息接收者将消息即时推送到客户端浏览器,若客户端浏览器对应的用户不在线,则将消息持久化到数据库,上线后查找待处理消息并展示给用户。After the listener obtains the message, it parses the message body to obtain the message content and recipient information, obtains the online user list through pushlet and finds the message recipients, and then pushes the message to the client browser immediately. If the user corresponding to the client browser does not When online, the messages are persisted to the database. After going online, the messages to be processed are searched and displayed to the user.
客户端及服务端的具体信息处理过程参见实施例子一的详细说明。For the specific information processing process of the client and server, please refer to the detailed description of Implementation Example 1.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection scope of the present invention.
上述虽然结合附图对本发明的具体实施方式进行了描述,但并非对本发明保护范围的限制,所属领域技术人员应该明白,在本发明的技术方案的基础上,本领域技术人员不需要付出创造性劳动即可做出的各种修改或变形仍在本发明的保护范围以内。Although the specific embodiments of the present invention have been described above in conjunction with the accompanying drawings, they do not limit the scope of the present invention. Those skilled in the art should understand that based on the technical solutions of the present invention, those skilled in the art do not need to perform creative work. Various modifications or variations that can be made are still within the protection scope of the present invention.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911168550.3ACN111124703B (en) | 2019-11-25 | 2019-11-25 | Method and system for automatically reminding processing work in cluster environment |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911168550.3ACN111124703B (en) | 2019-11-25 | 2019-11-25 | Method and system for automatically reminding processing work in cluster environment |
| Publication Number | Publication Date |
|---|---|
| CN111124703A CN111124703A (en) | 2020-05-08 |
| CN111124703Btrue CN111124703B (en) | 2024-03-22 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201911168550.3AActiveCN111124703B (en) | 2019-11-25 | 2019-11-25 | Method and system for automatically reminding processing work in cluster environment |
| Country | Link |
|---|---|
| CN (1) | CN111124703B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114513500B (en)* | 2022-01-19 | 2024-06-04 | 统信软件技术有限公司 | Method, device, system and computing device for batch installation of browser plug-ins |
| CN115174296B (en)* | 2022-05-30 | 2024-03-22 | 青岛海尔科技有限公司 | Equipment function access method and device, storage medium and electronic device |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103442072A (en)* | 2013-09-02 | 2013-12-11 | 百度在线网络技术(北京)有限公司 | Method and device for pushing traffic information related to user schedules |
| CN104092767A (en)* | 2014-07-21 | 2014-10-08 | 北京邮电大学 | A publish/subscribe system with added message queue model and its working method |
| CN105162687A (en)* | 2015-08-11 | 2015-12-16 | 甘肃万维信息技术有限责任公司 | WEB-based real-time message push method |
| CN110019240A (en)* | 2017-12-29 | 2019-07-16 | 中国移动通信集团北京有限公司 | A kind of service data interaction method, apparatus and system |
| CN110113420A (en)* | 2019-05-08 | 2019-08-09 | 重庆大学 | Distributed Message Queue management system based on NVM |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103442072A (en)* | 2013-09-02 | 2013-12-11 | 百度在线网络技术(北京)有限公司 | Method and device for pushing traffic information related to user schedules |
| CN104092767A (en)* | 2014-07-21 | 2014-10-08 | 北京邮电大学 | A publish/subscribe system with added message queue model and its working method |
| CN105162687A (en)* | 2015-08-11 | 2015-12-16 | 甘肃万维信息技术有限责任公司 | WEB-based real-time message push method |
| CN110019240A (en)* | 2017-12-29 | 2019-07-16 | 中国移动通信集团北京有限公司 | A kind of service data interaction method, apparatus and system |
| CN110113420A (en)* | 2019-05-08 | 2019-08-09 | 重庆大学 | Distributed Message Queue management system based on NVM |
| Publication number | Publication date |
|---|---|
| CN111124703A (en) | 2020-05-08 |
| Publication | Publication Date | Title |
|---|---|---|
| US20170149715A1 (en) | System and method for providing an actively invalidated client-side network resource cache | |
| US8799400B2 (en) | System and method for managing multiple queues of non-persistent messages in a networked environment | |
| EP2013764B1 (en) | Managing rich presence collections | |
| EP2115976B1 (en) | Method and system for resource-based synchronization between endpoints in a web-based real time collaboration | |
| EP2013763B1 (en) | Managing rich presence collections | |
| US12160321B2 (en) | Multiplexing message distribution within group-based communication system | |
| US20140372516A1 (en) | System and method for providing a scalable translation between polling-based clients and connection-based message queues | |
| WO2021237433A1 (en) | Message pushing method and apparatus, and electronic device and computer-readable medium | |
| US20090287761A1 (en) | Cached message distribution via http redirects | |
| US7836123B2 (en) | System and method for non-HTTP session based publish/subscribe support using pre-emptive subscriptions | |
| US20080244051A1 (en) | Method And System For Managing Dynamic Associations Between Folksonomic Data And Resources | |
| US20120096073A1 (en) | Local polling method and system for real time updating of web-based services | |
| CN112751748B (en) | Session message management method, device, server and readable storage medium | |
| US20080250149A1 (en) | Methods And System For Providing Concurrent Access To A Resource In A Communication Session | |
| EP2891297A1 (en) | Shared resource and session model using presence data | |
| US8665311B2 (en) | Methods and apparatus for collaboration | |
| US11283725B2 (en) | Event content delivery | |
| US20040039776A1 (en) | System and method for efficient data refresh | |
| CN111124703B (en) | Method and system for automatically reminding processing work in cluster environment | |
| CN113507498B (en) | A data exchange method and system for government hall equipment | |
| CN113132745B (en) | Live broadcast service system, method and server | |
| CN106411694B (en) | System and method for broadcasting content to recipient devices using XMPP | |
| CN110798495B (en) | Method and server for end-to-end message push in cluster architecture mode | |
| US8755397B2 (en) | Asynchronous communication in an unstable network | |
| CN116308671A (en) | Online bidding method based on MQTT protocol, electronic equipment and storage medium |
| 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 | ||
| CB02 | Change of applicant information | Address after:185 Jingsi Road, Shizhong District, Jinan City, Shandong Province Applicant after:Shandong luruan Digital Technology Co.,Ltd. Applicant after:STATE GRID SHANDONG ELECTRIC POWER Co. Address before:185 Jingsi Road, Shizhong District, Jinan City, Shandong Province Applicant before:SHANDONG LUNENG SOFTWARE TECHNOLOGY Co.,Ltd. Applicant before:STATE GRID SHANDONG ELECTRIC POWER Co. | |
| CB02 | Change of applicant information | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |