Search code examples
javaspringspring-bootspring-batchspring-cloud-dataflow

How to Limit the Job Execution Ids Listings in Spring-data-flow-server's Task Execution Details page?


I have a set of Spring boot batch jobs, which I have deployed in Spring cloud data flow serve. I'm using local server configuration. But I also want the Scheduling option for each jobs inside my application. So as mentioned in document Scheduling for Local Config for Scheduling jobs using local configuration, I use rest services along with @Scheduled annotation to kick start the job or otherwise knows as task in SCDF.

These scheduled jobs are supposed to run at 15 minutes intervals for several days. And there are 10 jobs. So what's happening when I launch the job using REst API is,

  • Job gets launched and gets executed on scheduled intervals. Job Id link is produced in the Task Execution Details page.
  • Job gets launched again as per the scheduled interval and the new Job Id links is produced along with the previous Job Id. Since these are all jobs that would have several executions (500+) over several days, in the Task Execution Details page theere would be 100s of the Job Id present. And there's no scroll bar and it occupies more than half page.
//Job Config
    @Configuration
    @EnableBatchProcessing
    @EnableTask
    public class Job1Loader {
    @Bean
        public Job loadJob1()
        {
            return jobBuilderFactory().get("JOb1Loader")
                .incrementer(new RunIdIncrementer())
                .flow(job01_step01())
                .end()
                .build();;//return job
    }

Rest Controller

@RestController
public class JobLauncherController {

    Logger logger = LoggerFactory.getLogger(JobLauncherController.class);

    @Autowired
    JobLauncher jobLauncher;

    @Autowired
    @Qualifier(value = "loadJob1")
    Job job1;

    @Scheduled(cron ="0 */2 * * * ?")
    @RequestMapping("/LaunchJob1")
    public String LaunchJob1() throws Exception
    {
        logger.info("Executing LaunchJob1");
        JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis())
                .toJobParameters();
        jobLauncher.run(job1, jobParameters);

        return "Job has been launched";
    }
}

So my question is this. How to limit the number of job id's listed in "Task Execution Details" page to minimum of 10 job id's. Or is there a possibility of introducing a scroll bar when certain thershold reaches for Job id count. Attached the screenshot for better unedrstanding.

Job Execution Ids


Solution

  • Currently, the REST API for Task execution response which includes the JobExecutionIds doesn't have such filtering options. What you mention above is more than a feature request than an issue :-)

    Would you mind creating a feature request in here and of course, you are welcome to contribute by providing a Pull Request with the changes.