Vinicius Duarte Vinicius Duarte - 7 months ago 28
Javascript Question

notification to the user when a table in the database change

I'm using Spring for this project and I need the best solution for this problem, because this affect the performance the system. Is better using Javascript or create a method on the Java ?

Answer

From the web server:

  1. Poll the database, and check for new data
  2. Or listen for notifications from the database. This is the preferred method. You'd need PostgreSQL or Oracle to do this though

From the web browser:

  1. Reload the page using the Refresh header (don't do this)
  2. Poll the server using AJAX
  3. Use COMET
  4. Use Server-Sent Events. This is probably the lightest weight.
  5. Use WebSocket

Here's how to do it with Spring, PostgreSQL, and WebSocket: http://blog.databasepatterns.com/2014/04/postgresql-nofify-websocket-spring-mvc.html

Comments