Note that there are some explanatory texts on larger screens.

plurals
  1. PORestart a new instance of a job that is not restartable
    primarykey
    data
    text
    <p>I have defined a Spring-Batch Job with Parameter restart="false", because I do not want the same instance of the Job to be started again.</p> <pre><code>&lt;batch:job id="myJob" restartable="false"&gt; &lt;batch:step id="myStep"&gt; &lt;batch:tasklet&gt; ... &lt;/batch:tasklet&gt; &lt;/batch:step&gt; &lt;/batch:job&gt; </code></pre> <p>The Job is referenced in two other more highlevel jobs:</p> <pre><code>&lt;batch:job id="hightLevelJob1" restartable="false"&gt; &lt;batch:step id="myHighLevelJob1Step1" next="..."&gt; &lt;batch:job ref="myJob"/&gt; &lt;/batch:step&gt; ... &lt;/batch:job&gt; &lt;batch:job id="hightLevelJob2" restartable="false"&gt; &lt;batch:step id="myHighLevelJob2Step1" next="..."&gt; &lt;batch:job ref="myJob"/&gt; &lt;/batch:step&gt; ... &lt;/batch:job&gt; </code></pre> <p>I now have two JUnit-Tests that each starts one of the high level jobs:</p> <pre><code>@Autowired private JobOperator jobOperator; @Test public void testHighLevelJob1() throws JobExecutionException { final Long executionId = jobOperator.startNextInstance("myHighLevelJob1"); ... } @Test public void testHighLevelJob2() throws JobExecutionException { final Long executionId = jobOperator.startNextInstance("myHighLevelJob2"); ... } </code></pre> <p>The first test runs fine, while the second one throws a JobRestartException:</p> <pre><code>JobInstance already exists and is not restartable </code></pre> <p>I am using jobOperator.startNextInstance() so it creates a <strong>new</strong> job. However, it seems this only applies for the high level job that is started. It looks like Spring-Batch tries to re-use the referenced job.</p> <p>How can I configure the jobs to also have a new instance of the referenced job created everytime?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload