Announcement Announcement Module
Collapse
No announcement yet.
Stoping -Spring batch Job Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stoping -Spring batch Job

    Hi

    I am trying to stop a Spring batch job which is running , i am using below command to stop ajob , it doesn't seemed to be working .

    "mvn exec:java -Dexec.mainClass=org.spring
    framework.batch.core.launch.support.CommandLineJob Runner
    -stop -Dexec.args="ingestor-config.xml job"

    help me to stop a job gracefully .

  • #2
    I would try running this through without maven and see what happens.

    Comment


    • #3
      I have tried with out using maven also .. i ws not able to stop a job . it just keeps running .

      Comment


      • #4
        Does it use a custom tasklet, or one from Spring Batch (the framework step implementations look for stop signals only after a tasklet finishes its execute method)? Is it healthy in other ways (processing data) or in an infinite loop (where it won't be able to get out and look for the signal).

        Comment


        • #5
          i use below config for tasklet creation,Which uses spring batch tasklet


          <batch:step id="step1">
          <batch:tasklet job-repository="jobRepository" transaction-manager="transactionManager" >
          <batch:chunk reader="csvmultiResourceReader" writer="multipleItemWriter" commit-interval="1000" />
          <batch:listeners>
          <batch:listener ref="csvNameListener" />
          </batch:listeners>
          </batch:tasklet>
          </batch:step>

          My job config

          <batch:job id="job" job-repository="jobRepository" restartable="true"> <batch:step id="fileSplitterStep" parent="step1"" />


          I was trying to stop a job which has ben started and to restart. Job Stops once all the csv's are read . I want to stop it in middle when it is processing and restart the same .Is their any way we can do it so .

          thanks
          Last edited by didilip; Jan 13th, 2011, 03:52 AM.

          Comment


          • #6
            You have commit-interval=1000, so at least 1000 items will be processed. Is that the behaviour your are seeing?

            Comment


            • #7
              I have initially started with 100 items for commit interval ,But we deal with a millions of contents so , i just made for fast processing commit interval as 1000.

              Behavior of stopping is same when i used 100 r 1000 ,i have checked for both.

              Comment


              • #8
                How do you know that the job is still running? Do you see the step execution being updated?

                Comment


                • #9
                  After triggering stop command ,I am still seeing in logs that it is picking next chunk of items and processing . After Complet reading of items it shows Completed , Till then it keeps running .

                  Comment


                  • #10
                    Are the stop command and the running job actually using the same repository?

                    Comment


                    • #11
                      yes , It is using the same repository .

                      Comment


                      • #12
                        I am using my own transaction manger , does it have any role in not stoping the Job .

                        Transaction manger doesn't check any thing specific .

                        Below is the config for that
                        <bean id="transactionManager" class="com.real.ramses.ingestor.transformer.Ingest orTransactionManager" />

                        <bean id="jobRepository" class="org.springframework.batch.core.repository.s upport.MapJobRepositoryFactoryBean">
                        <property name="transactionManager" ref="transactionManager"/>
                        </bean>

                        Comment


                        • #13
                          Ah. Well it's not the transaction manager as such, but the repository is a problem. If you use a Map JobRepository, how do you expect it to be shared between the two processes (the one that launches it and the one that stops it)? You can still call JobExecution.stop() on the original running instance if you keep a reference to it, but using CommandLineJobRunner you will always be in a new process, so there is no way to exchange data without an external JobRepository.

                          Comment


                          • #14
                            thanks , I was trying to find the example which has used external repository , I Haven't found any , All of the examples use either MapRepository or simpleJob Repository .

                            If you can point me to any of the examples which uses external Repository , That will help me a lot .

                            thanks

                            Comment


                            • #15
                              I am trying External repo as DERBY Db ,
                              I have created tables and the tables required for sequece in derby .

                              But getting below error once i start a job , Is their any particular steps i need to follow ?


                              [mmandLineJobRunner.main()] ERROR CommandLineJobRunner - Job Terminated in error: Could not obtain IDENTITY value; nested exception is java.sql.SQLSyntaxErrorException: 'DUMMY' is not a column in table or VTI 'APP.BATCH_JOB_SEQ'.

                              Comment

                              Working...
                              X