简体   繁体   中英

HTML Web Application Notification System

I'm using Play Framework 2.3 (Java) and MySQL.

I'm building a notification system that reads from a "notifications" table in MySQL.

I've tried using AJAX polling where a request is sent asynchronously every 30 seconds, the table is read and if any new notifications exist, are sent via JSON back to the client. However, the performance is concerning, especially with many concurrent users.

What's the best way to build such a system? Are there any particular Java libraries that would work well for this?

Thanks in advance.

I see I read too fast, you're using the Play Framework, which I don't know. But a quick search reveals that it also has websocket capabilities:

http://www.playframework.com/documentation/2.3.x/JavaWebSockets

---- Old answer below ----

If you're using JEE7, why not try to use websockets? It would limit your application to 'newer' browsers, supporting websockets, but it would improve performance, since the connection is bi-directional and suffers less from overhead.

More information on the subject can be found here:

http://docs.oracle.com/javaee/7/tutorial/doc/websocket.htm

I've also found the following example very useful:

http://mgreau.com/posts/2013/11/11/javaee7-websocket-angularjs-wildfly.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM