Announcement Announcement Module
Collapse
No announcement yet.
problem with step jobs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem with step jobs

    Hello
    I have configured a batch that run every step as separate jobs by using what is decribed in the reference manual as Step job
    This kind of approach is very useful because I can start the single batch directly as a single Job or as part of a more complex job that we can call "job network".
    for example I have a mainNetJob:

    Code:
    <import resource="classpath*:/META-INF/spring/batch/jobs/*.xml" />
        <job id="mainNetJob"
            xmlns="http://www.springframework.org/schema/batch"  restartable="true" incrementer="incrementer">
            <step id="mainNetJob.closeconnections" next="mainNetJob.userLogout" >
                <job ref = "closeconn" job-launcher="syncJobLauncher" job-parameters-extractor="jobParametersExtractor"/>
            </step>        
             <step id="mainNetJob.userLogout" next="mainNetJob.postReminder">
                <job ref = "userLogoutJob" job-launcher="syncJobLauncher" job-parameters-extractor="jobParametersExtractor"/>
             </step>    
             <step id="mainNetJob.postReminder" next="mainNetJob.checkMails">
                <job ref = "postReminderJob" job-launcher="syncJobLauncher" job-parameters-extractor="jobParametersExtractor"/>
             </step>             
             <step id="mainNetJob.checkMails" >
                <job ref = "checkMailsJob" job-launcher="syncJobLauncher" job-parameters-extractor="jobParametersExtractor"/>
             </step>
        </job>
    then I can define (even in separate xml saved in the folder META-INF/spring/batch/jobs) each single Job
    for example and once for all, in closeconn.xml I have defined:
    Code:
    <job id = "closeconn" xmlns="http://www.springframework.org/schema/batch" restartable="true" incrementer="incrementer">
             <step id="closeconnStepInitUpd" next="closeconn1">
                <tasklet ref="closeconnInitUpd"/>
            </step>        
            <step id="closeconn1" next="closeconn2" >
                <tasklet>
                <chunk reader="closeconnReader1" writer="closeconnWriter"
                           commit-interval="5" />
                </tasklet>
            </step>
             <step id="closeconn2" >
                <tasklet>
                <chunk reader="closeconnReader2" writer="closeconnWriter"   
                           commit-interval="5" />
                </tasklet>
            </step>
         </job>


    If I run each Job with job-launcher="syncJobLauncher" each step will be executed only when previous is finished with an "asycJobLouncher" I can decide to execute some or all step together.
    This is very nice! and is 100% working

    The only problem I see, is when I get a look in Spring-batch-admin-console for Job execution: In the mainNetJob I can only see the steps of mainNetJob but I have no way to navigate to the real Job.
    I need to navigate to the "real" job because if for example the "closeconn" job read 1000 records, in the mainNetJob.closeconnections Step I always see 0 record read, 0 write...which are useless informations.

    I get a look to modify the console but I soon realize that I have no information on DB to link a step of a "network" job to the "real" job
    to patch this for a while, I changed the BATCH_JOB_EXECUTION by adding a column FROM_BSE_ID ( that is "from batch step execution")
    with the meaning of the ID of the Step that started the execution of this job

    This obviously had required to change a lot of class in batch core to let the id of the job to be written in the BATCH_JOB_EXECUTION.FROM_BSE_ID.
    This because I can get the ID of the step-job only when I am in the method of JobStep.doExecute and need put it in the jobExecution instance class "BEFORE" it will be persited.
    Unfortunately the persistence of jobExecution id done by jobLauncher by calling the jobrepository ( I found it in SimpleJobRepository.createJobExecution)
    The only way I found to pass the stepJobID from the JobStep class to SimpleJobRepository class. is to pass it as a JobParameter.... this solution work But Is disgusting me...

    I don't know if I well explain this issue but I hope so.
    Could somebody suggest me something better to realize that link betweeen step job and jobs?
    Is a change in the way String Batch jobs works that could interest somebody else?

    thank you
    Franco

  • #2
    Sorry for not getting to this sooner. We are in the process of moving to StackOverflow for our forums.
    This question is probably a better candidate for StackOverflow, perhaps against the #spring-batch tag. If you do post it there, please reply here with the link. Thanks!

    Comment

    Working...
    X