I have my custom command line runner implementation which add a job parameter in run method. I’m invoking my spring task from a SCDF task scheduler. The problem is my commandlinerunner run is not not executed sometimes so, the parameter is not passed leading to my failure of my job. My question is Why is my custome commandlinerunner not getting executed all the times? Will there be any default commandline runner that take precedence over custom command line and won’t let the custom command line runner execute?
@Component
public class TaskRunner implements CommandLineRunner {
private final JobLauncher jobLauncher;
private final Job myJob;
private static final Logger LOGGER = LoggerFactory.getLogger(TaskRunner.class);
public TaskRunner(JobLauncher jobLauncher, Job myJob){
this.jobLauncher = jobLauncher;
this.myJob = myJob;
}
@Override
public void run(String... args) throws Exception {
String currentDateTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
LOGGER.info("Current Date Time is {}", currentDateTime);
JobParameters jobParameters = new JobParametersBuilder()
.addString("RUNTIMESTAMP", currentDateTime)
.toJobParameters();
jobLauncher.run(myJob, jobParameters);
}
}
2