Results 1 to 2 of 2

Thread: JobRepository.createJobExecution(String, JobParameters)

  1. #1
    Join Date
    Mar 2010
    Posts
    5

    Default JobRepository.createJobExecution(String, JobParameters)

    Hi,
    I'm fooling with the following:

    In a Junit test case I have this:
    JobExecution jobEx = repository.createJobExecution(String name, JobParameters params);

    Running the above line creates a row in (among others) the Batch_Job_Execution table with a Job_Execution_ID, a Job_Instance_ID and with the STATUS=starting and EXIT_CODE=unknown.

    That is all, the test case ends. So far so good?

    In another method in another Junit test case, I try and restart thatjob using the JobOperator. I retrieve the executionID from the database:
    operator.restart(Long executionID)

    I get the Exception that the job is already running.

    What am I missing here?

    What is the purpose of repository.createJobExecution(--) method? Why would I be interested in it?

    I can envision the use case where I might create some number of JobExecutions and go back and run them later, but the framework is not permitting me to do this.


    Thanks in advance for you comments.

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    Look at JobExecution.isRunning(). Until the execution is updated in the job repository with a status and an endTime, the JobLauncher which you are using indirectly through the JobOperator, assumes that it is still running.

    JobRepository.createJobExecution() is there for the benefit of clients who want to launch a job execution (specifically a JobLauncher). You probably aren't interested in it as a normal user - only if you want to write your own JobLauncher.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •