I have a cron job that counts from 0 to 1 or to any integer on the fly to indicate current number of asynchronous jobs over REST. If for any reason there is bad connectivity so that instead of getting status code 200, my system simply does not return any value.
My question is what is best practice to ensure that when connectivity is back alive I can ensure my counter (which is stored in Mongodb) always return from whichever state, to start at 0 regardless? For example state could be at 3 when connectivity is lost, and when system is connected again to begin with 0 in order to synchronise sending and receiving.