Announcement Announcement Module
Collapse
No announcement yet.
How can i restart the failed job ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can i restart the failed job ?

    Hi,
    I implemented my own flatfileitemreader for reading the data from file, and it stores the seek position of processing file so dat from next time if the job restarted reader reads the data from file based on seek position. here processing file contains real time data(i.e reader returns null until new data arrived into the processing file). now i want to monitor my job.. if the job fails how can i restart my job automatically?

    I made the above job as infinite process by calling 2 stpes(1 calling 2 and 2 calling 1).. config xml entry given below


    <step id="step1" next="step2">
    <tasklet transaction-manager="jobRepository-transactionManager" allow-start-if-complete="true">
    <chunk **** </chunk>
    </tasklet>
    </step>
    <step id="step2" next="step1">
    <tasklet transaction-manager="jobRepository-transactionManager" allow-start-if-complete="true">
    <chunk **** </chunk>
    </tasklet>
    </step>




    Need suggestions for above approach... is there any better way i can do the same.. and how can i monitor and restart my job ?

    Thanks in Advance.

  • #2
    If you want an infinite loop there's nothing wrong with what you did, except that you are going to fill up the JobRepository with zillions of StepExecutions that have readCount=0. Would it be better to write a StepExecutionListener that blocks until the data are available? Or even do that in the JobLauncher client, then you can do the automatic restart in the same place? E.g.

    Code:
    BatchStatus result = BatchStatus.FAILED;
    while (result==BatchStatus.FAILED) {
        waitForMoreData();
        result = jobLauncher.run(...).getStatus();
    }
    Last edited by Dave Syer; May 4th, 2011, 01:07 PM. Reason: formatting

    Comment


    • #3
      Thanks Dave..

      I am facing one more issue in the above spring batch job.. I am trying to start the above spring batch job as OSGI bundle.

      Here in my bundle activator .. start method i writting below code

      CommandLineJobRunner.main(new String[] { "ApplicationContext.xml",
      "JobName" });

      to strat the spring batch job when my bundle start cmd issued.. but here i am facing the problem like.... spring batch unable to find the xml(application context) file...

      here shall i need to write my own "CommandLineJobRunner" clinet or is dere anty way to handle this issue ?

      Comment


      • #4
        When starting job with OSGI bundle, can you check if the file "ApplicationContext.xml" is in the classpath? the name here is same as in your classpath?

        Comment

        Working...
        X