Reputation: 63
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.
Upvotes: 1
Views: 779
Reputation: 215
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
Upvotes: 2