Announcement Announcement Module
No announcement yet.
Persistent Job queue, and some general questions about SB. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Persistent Job queue, and some general questions about SB.

    I need to integrate something which will allow me to:
    - create persistent Jobs (for example mail notification, report generation etc)
    - launch them one-after-another (one thread at a time) - just like a persistent queue
    - in case of fail re-run such a job after let's say 20 minutes - try to do this 20 times, then report error and abandon.

    Some of these Jobs will be time-triggered, some will be triggered by webapp action.
    Before I spotted Spring Batch I thought about using Quartz for this, but in many situation my Jobs are not time-oriented, a safe, persistent queue with guaranteed job invocation would suffice.
    Is using SB for these tasks a good idea? Do you know anything other than SB that should I use?

    That saying, there is a lot of white holes in SB documentation in RC1 at this moment... Is there any API for querying Jobs by selected criteria? I mean something like "find all failed", something that would allow me to rerun failed jobs on demand etc?


  • #2
    Spring Batch is not intended to be a Scheduler, I think this is why you're finding 'holes' in the documentation. It is entirely a processing framework and is intended to work in conjunction with a scheduler, not instead of one.


    • #3
      Thank you very much for you answer. Please bear with me, I just want to determine if this is a right tool for my Job.

      So solution for my problem would be a something like this:

      1. Declare i.e. SendMailJob
      2. SimpleTrigger to Create job instance for SendMailJob to send something to [email protected]
      3. If SendMailJob step fails (timeout etc.), schedule using Quartz it's next invocation after 20 minutes.
      4. Quartz invokes step 2.
      And repeat 2. - 4. until success or invocation count reaches maximum amount.

      Is it the way you would go with this?

      Can I guarantee that there is only one instance of SendMailJob, ReportGeneratingJob etc running concurrently? What would be the cleanest way of achieving this?

      Thank you for you time,


      • #4
        Ah, I would honestly wrap the Spring Batch JobLauncher in a RetryTemplate and let Quartz do the initial kick off. If it fails you can let the RetryPolicy determine when to kick off again. You can find more information on the RetryTemplate in the reference docs in Chapter 6.