Vinicius Duarte Vinicius Duarte - 10 months ago 39
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 ?


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: