Announcement Announcement Module
Collapse
No announcement yet.
Batch Jobs Dependency Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Batch Jobs Dependency

    Hi,

    Is there a way to create dependency for two different jobs in the springbatch. For example: the second job won't run, until the first job is completed successfully?
    And how to get the latest job instance by just having the jobName only?

    Thanks very much.

  • #2
    Originally posted by rudithu View Post
    Is there a way to create dependency for two different jobs in the springbatch. For example: the second job won't run, until the first job is completed successfully?
    In that simple scenario you should just make them steps in the same job. More complex dependencies will be supported natively in 2.0. In the meantime the easiest way is to inject a RepeatListener into the StepOperations of your Step which vetoes the execution of the step before it starts (the listener also probably needs to implement StepExecutionListener so it can pick up context information to make its decision).

    Originally posted by rudithu View Post
    And how to get the latest job instance by just having the jobName only?
    In 2.0 you have a JobExplorer. In 1.1 you have to hang on to the JobExecution aftter it is launched. The JMX sample does this (adhoc-*-contexet.xml).

    Comment


    • #3
      Hi Dave,

      Thanks very much for the reply.

      In that simple scenario you should just make them steps in the same job. More complex dependencies will be supported natively in 2.0. In the meantime the easiest way is to inject a RepeatListener into the StepOperations of your Step which vetoes the execution of the step before it starts (the listener also probably needs to implement StepExecutionListener so it can pick up context information to make its decision).


      For my current scenario is not that simple. I have 2 jobs that are dependent on one job. Probably I may put them in as the 3 steps (assume one job is one step for simplification). First step may run the first job, second step may run second job, skip the job if it's failed or complete, then the third step may run the third job and skip if it's complete.

      I write the steps using tasklet step and wondering how to implement the skip logic for that. I only see the implementation for SimpleStepFactoryBean, let me know if u have some example for tasklet please, also the example for RepeatListener .

      Thanks very much for your help.

      Best Regard,
      Rudithu

      Comment


      • #4
        TaskletStep is even easier. You just put the skip logic in your tasklet (having implemented StepExecutionListener probably, so you can pick up the execution context from the job execution).

        Comment

        Working...
        X