I have a web server and some types of data stores. I need synchronization between both servers. Web servers always work, and I try to maintain data servers as long as possible.
Both have MySQL databases, and I already have scripts to synchronize them. I made a java program that receives new data fields from a web server and stores them in its own database every 10 seconds. Unlimited java thread does this. This will be the part of the code that does this:
Timer timer;
Date current_date = new Date() ;
timer = new Timer();
timer.scheduleAtFixedRate(new doCheck(), current_date, 10 * 1000);
The constructor of the doCheck () class retrieves data from the web server in XML format. There is no direct mysql connection with servers.
The real problem:
But when this script starts 24/7, after a certain period, like after a couple of days, the script (basically a stream receiving XML from the web server) suddenly stops working, and synchronization is completely disabled.
Possibility No. 1: Disconnecting the Internet: I tried to disconnect the network cable and it started to throw exceptions, but as soon as I plugged in the wire again, it started to work fine.
Possibility No. 2: Any exception in the code, etc .: I support logs, but in most cases it stops suddenly without any exceptions or errors.
Possibility No. 3: manual stream cancellation: no one touches the server: P and there is only one button to cancel it, so this is not possible.
Why is this happening? I just want this script to work unlimited time.