tags:

views:

51

answers:

4

In my webservice all method calls submits jobs to a queue. Basically these operations take long time to execute, so all these operations submit a Job to a queue and return a status saying "Submitted". Then the client keeps polling using another service method to check for the status of the job.

Presently, what I do is create my own Queue, Job classes that are Serializable and persist these jobs (i.e, their serialized byte stream format) into the database. So an UpdateLogistics operation just queues up a "UpdateLogisticsJob" to the queue and returns. I have written my own JobExecutor which wakes up every N seconds, scans the database table for any existing jobs, and executes them. Note the jobs have to persisted because these jobs have to survive app-server crashes.

This was done a long time ago, and I used bespoke classes for my Queues, Jobs, Executors etc. But now, I would like to know has someone done something similar before? In particular,

  • Are there frameworks available for this ? Something in Spring/Apache etc
  • Any framework that is easy to adapt/debug and plays well along with libraries like Spring will be great.

EDIT - Quartz

Sorry if I had not explained more, Quartz is good for stateless jobs (and also for some stateful jobs), but the key for me is very stateful persisted "job instances" (not just jobs or tasks). So for example an operation of executeWorkflow("SUBMIT_LEAVE") might actually create 5 job instances each with atleast 5-10 parameters like userId, accountId etc to be saved into the database.

I was looking for some support around that area, where Job instances can be saved into DB and recreated etc ?

A: 

I haven't used Quartz for a long time, but I suspect it would be capable of everything you want to do.

Jon Skeet
A: 

spring-batch plus quartz

Pangea
A: 

Depending upon the nature of your job, you might also look into spring-integration to assist with queue processing. But spring-batch will probably handle most of your requirements.

Mike Cornell
+1  A: 

Take a look at JBoss jBPM. It's a workflow definition package that lets you mix automated and manual processes. Tasks are persisted to a DB back end, and it looks like it has some asynchronous execution properties.

gibbss
I have had a look at jBPM long time ago but did not know asynchronous continuations existed. Thanks
Calm Storm