0

I have a Java Servlet which writes a message to the database. Some other tier picks up this message from the DB and processes it and updates the status of this message in the database. Meanwhile in the servlet, I have to keep polling the database to get an update on status of the message which was written earlier.

How can I implement a Callback instead of polls so that unnecessary database queries are avoided?

1 Answers1

0

I suppose you're talking about server push technologies. I suggest you to use HTML5 websockets for this. Use your same servlet with a websocket to communicate between both ends.

There are so many examples out there.

  1. Java WebSockets - In this example he uses jetty, but you can use jboss or tomcat for this.
  2. StackOverFlow post describe the same.
  3. pushing data for multiple clients from a server via websockets

try above links and it is worth for trying.

Community
  • 1
  • 1
Nomesh DeSilva
  • 1,649
  • 4
  • 25
  • 43