views:

19

answers:

0

I have a single threaded message listener that listens for the incoming messages.The received messages are persisted in a database as they are recieved.

There is a message A and associated message B follows it with a reference it.In Some Odd occurences, B arrives before A. Now in this case, There has to be 3retries after some 'x' equal intervals to see if A has arrived and then persists the association.

As the message listener is single threaded if we put the thread to sleep the whole system would be affected. So there has to be a separate thread retrying.

Can we use Quartz Job Scheduler for this purpose to avoid handling multiThreading issues and to have a PERSISTENT STORE of the in any of the following 2 ways,

  1. Schedule a Job in Quartz for 3 times and keep track of a flag in the JobDataMap to check if previous retries succeeds then return without doing anything

OR

2.Schedule a Job to retry once and then if the retry fails schedule the same job after a few seconds.

Can quartz be used only for repetitive jobs and not have some state information span across job or Is there any other better way to do this.