I have a Java web application, running in a cluster of Tomcat application servers and a shared SQL/JDBC database. Data from the database is cached in memory in each instance of the web app.My web application needs to update the database periodically with weather report data from a source outside of my web application (i.e. a background thread periodically collects and writes a whole bunch of data rows into a table in the database using SQL). Only one instance of my web application in the cluster should do this and then make the other instances aware that the data in the database has changed so that they can flush their caches and start using the updated data from the database. The propagation of the update to the database doesn't need to be real time.What is the best practice to achieve this? How do I negotiate, which node will be the one to perform the updates? Which JEE technologies could I use? I want to avoid simply polling for changes in the database.
Java Web Application in Cluster with Shared Database. How to Negotiate an Instance to do Updates? How to Notify Instances of Updates?
java;architecture;web applications;cluster
Using a messaging broker seems like the best tool to inform other applications that they should update rather than polling (which is fine really too).http://www.rabbitmq.com/Locking the database table for writing is what you want to prevent race conditions.