Hey fellows I hope you are doing well!
So the problem is like this: I have a web server and some data storage kind of servers. What I need is synchronization between both the servers. Web servers are always up, and I try to keep the data servers up as long as possible.
Both have mysql databases and I already have written scripts to synchronize them. I have made a java program which gets the new data fields from the web server and stores them in its own database every 10 seconds. An unlimited java thread does this. This would be the piece of code which does this:
Timer timer;
Date current_date = new Date() ;
timer = new Timer();
timer.scheduleAtFixedRate(new doCheck(), current_date, 10 * 1000);
The constructor of the class doCheck() is fetching data from the web server in XML format. No mysql direct connection b/w the servers is made.
THE REAL PROBLEM:
But when this script runs 24/7, after a certain period like in a couple of days, the script (basically a thread fetching xml from a web server) suddenly stops running and the synchronization totally disconnects.
Possibility #1: Internet disconnection: I tried unplugging the network cable, and it started giving exceptions, but as soon as I reconnected the wire, it start working perfectly fine.
Possibility #2: Any exception in the code etc.: I am maintaining logs, but most of the times it stops suddenly without and kind of exception or error.
Possibility #3: Manual cancellation of thread: No one touches the servers :P and there is just one button to cancel it, so this is not possible.
Is there any experienced programmer to tell me why does this happen?? I just want this script to run unlimited times.