Handling Weblogic server crash
Here is my problem. I want to deploy a Java application to a Weblogic server. This application fetches contacts from the database in batches, 100 contacts at a time. When a batch is processed, all the contacts are updated with the status 'Processed' in the database and another 100 contacts are fetched.
Now, my concern is - what happens if the application has processed, lets say, 70 contacts, and then the Weblogic server crashed. I have a startup class defined which will restart my application on server restart. However, since those 70 contacts that were processed were not updated in the database as "Processed", they will be fetched again and processed again which is unacceptable.
What I want is to somehow be able to reinitialize and get my 100 contacts back into the application, without loosing the knowledge of which contacts were and were not processed.
The simplest way I know how this can be done is by updating each contact right after it has been processed. However, this is pretty heavy on the database.
If anyone else has encountered such a problem and knows another way to audit the changes made, or any other way of solving this problem, please share.
You need to know Transaction
Application servers support transaction, Weblogic has quite good support for it. you just need to put you code in a transaction so that it can be treated as a single unit of work. even you can use database commit mechanism