Our server web app will handle jobs that are requested by REST API requests.
Ideally if the server dies during a job (ie: plug pulled), the job should resume or restart at startup.
A very convenient way to process these jobs is in a separate thread using some of the concurrent utility classes in Java 5. The only issue is, given a failure, you need to have written down the job details and create a process that reads these details at startup and resumes the jobs. This seems like a pain to do.
An alternate approach is to use a queue where user makes request, we write to queue, then read from queue and perform job and only remove the message when the job is complete. This makes it easy to resume the job on startup as the server will just read from the queue on startup and resume the process.
Are there any better approaches to this scenario?