|
|
@ -98,9 +98,11 @@ class JobLauncherApplicationRunnerTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void retryFailedExecution() {
|
|
|
|
void retryFailedExecution() {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
|
|
|
|
PlatformTransactionManager transactionManager = context.getBean(PlatformTransactionManager.class);
|
|
|
|
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext(context);
|
|
|
|
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext(context);
|
|
|
|
Job job = jobLauncherContext.jobBuilder()
|
|
|
|
Job job = jobLauncherContext.jobBuilder()
|
|
|
|
.start(jobLauncherContext.stepBuilder().tasklet(throwingTasklet()).build())
|
|
|
|
.start(jobLauncherContext.stepBuilder().tasklet(throwingTasklet())
|
|
|
|
|
|
|
|
.transactionManager(transactionManager).build())
|
|
|
|
.incrementer(new RunIdIncrementer()).build();
|
|
|
|
.incrementer(new RunIdIncrementer()).build();
|
|
|
|
jobLauncherContext.runner.execute(job, new JobParameters());
|
|
|
|
jobLauncherContext.runner.execute(job, new JobParameters());
|
|
|
|
jobLauncherContext.runner.execute(job, new JobParametersBuilder().addLong("run.id", 1L).toJobParameters());
|
|
|
|
jobLauncherContext.runner.execute(job, new JobParametersBuilder().addLong("run.id", 1L).toJobParameters());
|
|
|
@ -111,9 +113,10 @@ class JobLauncherApplicationRunnerTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void runDifferentInstances() {
|
|
|
|
void runDifferentInstances() {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
|
|
|
|
PlatformTransactionManager transactionManager = context.getBean(PlatformTransactionManager.class);
|
|
|
|
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext(context);
|
|
|
|
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext(context);
|
|
|
|
Job job = jobLauncherContext.jobBuilder()
|
|
|
|
Job job = jobLauncherContext.jobBuilder().start(jobLauncherContext.stepBuilder().tasklet(throwingTasklet())
|
|
|
|
.start(jobLauncherContext.stepBuilder().tasklet(throwingTasklet()).build()).build();
|
|
|
|
.transactionManager(transactionManager).build()).build();
|
|
|
|
// start a job instance
|
|
|
|
// start a job instance
|
|
|
|
JobParameters jobParameters = new JobParametersBuilder().addString("name", "foo").toJobParameters();
|
|
|
|
JobParameters jobParameters = new JobParametersBuilder().addString("name", "foo").toJobParameters();
|
|
|
|
jobLauncherContext.runner.execute(job, jobParameters);
|
|
|
|
jobLauncherContext.runner.execute(job, jobParameters);
|
|
|
@ -128,9 +131,11 @@ class JobLauncherApplicationRunnerTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void retryFailedExecutionOnNonRestartableJob() {
|
|
|
|
void retryFailedExecutionOnNonRestartableJob() {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
|
|
|
|
PlatformTransactionManager transactionManager = context.getBean(PlatformTransactionManager.class);
|
|
|
|
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext(context);
|
|
|
|
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext(context);
|
|
|
|
Job job = jobLauncherContext.jobBuilder().preventRestart()
|
|
|
|
Job job = jobLauncherContext.jobBuilder().preventRestart()
|
|
|
|
.start(jobLauncherContext.stepBuilder().tasklet(throwingTasklet()).build())
|
|
|
|
.start(jobLauncherContext.stepBuilder().tasklet(throwingTasklet())
|
|
|
|
|
|
|
|
.transactionManager(transactionManager).build())
|
|
|
|
.incrementer(new RunIdIncrementer()).build();
|
|
|
|
.incrementer(new RunIdIncrementer()).build();
|
|
|
|
jobLauncherContext.runner.execute(job, new JobParameters());
|
|
|
|
jobLauncherContext.runner.execute(job, new JobParameters());
|
|
|
|
jobLauncherContext.runner.execute(job, new JobParameters());
|
|
|
|
jobLauncherContext.runner.execute(job, new JobParameters());
|
|
|
@ -149,9 +154,11 @@ class JobLauncherApplicationRunnerTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void retryFailedExecutionWithNonIdentifyingParameters() {
|
|
|
|
void retryFailedExecutionWithNonIdentifyingParameters() {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
|
|
|
|
PlatformTransactionManager transactionManager = context.getBean(PlatformTransactionManager.class);
|
|
|
|
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext(context);
|
|
|
|
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext(context);
|
|
|
|
Job job = jobLauncherContext.jobBuilder()
|
|
|
|
Job job = jobLauncherContext.jobBuilder()
|
|
|
|
.start(jobLauncherContext.stepBuilder().tasklet(throwingTasklet()).build())
|
|
|
|
.start(jobLauncherContext.stepBuilder().tasklet(throwingTasklet())
|
|
|
|
|
|
|
|
.transactionManager(transactionManager).build())
|
|
|
|
.incrementer(new RunIdIncrementer()).build();
|
|
|
|
.incrementer(new RunIdIncrementer()).build();
|
|
|
|
JobParameters jobParameters = new JobParametersBuilder().addLong("id", 1L, false).addLong("foo", 2L, false)
|
|
|
|
JobParameters jobParameters = new JobParametersBuilder().addLong("id", 1L, false).addLong("foo", 2L, false)
|
|
|
|
.toJobParameters();
|
|
|
|
.toJobParameters();
|
|
|
@ -187,9 +194,11 @@ class JobLauncherApplicationRunnerTests {
|
|
|
|
JobLauncherApplicationRunnerContext(ApplicationContext context) {
|
|
|
|
JobLauncherApplicationRunnerContext(ApplicationContext context) {
|
|
|
|
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
|
|
|
|
JobLauncher jobLauncher = context.getBean(JobLauncher.class);
|
|
|
|
JobRepository jobRepository = context.getBean(JobRepository.class);
|
|
|
|
JobRepository jobRepository = context.getBean(JobRepository.class);
|
|
|
|
|
|
|
|
PlatformTransactionManager transactionManager = context.getBean(PlatformTransactionManager.class);
|
|
|
|
this.jobs = new JobBuilderFactory(jobRepository);
|
|
|
|
this.jobs = new JobBuilderFactory(jobRepository);
|
|
|
|
this.steps = new StepBuilderFactory(jobRepository, context.getBean(PlatformTransactionManager.class));
|
|
|
|
this.steps = new StepBuilderFactory(jobRepository);
|
|
|
|
this.step = this.steps.get("step").tasklet((contribution, chunkContext) -> null).build();
|
|
|
|
this.step = this.steps.get("step").tasklet((contribution, chunkContext) -> null)
|
|
|
|
|
|
|
|
.transactionManager(transactionManager).build();
|
|
|
|
this.job = this.jobs.get("job").start(this.step).build();
|
|
|
|
this.job = this.jobs.get("job").start(this.step).build();
|
|
|
|
this.jobExplorer = context.getBean(JobExplorer.class);
|
|
|
|
this.jobExplorer = context.getBean(JobExplorer.class);
|
|
|
|
this.runner = new JobLauncherApplicationRunner(jobLauncher, this.jobExplorer, jobRepository);
|
|
|
|
this.runner = new JobLauncherApplicationRunner(jobLauncher, this.jobExplorer, jobRepository);
|
|
|
|