0

I've developed couple of Spring Batch jobs in Spring Boot web application. For easier maintenance, I used @EnableBatchProcessing(modular = true) like this:

@Configuration
@EnableBatchProcessing(modular = true)
public class BatchConfiguration {

    @Bean
    @ConditionalOnProperty(value="first.batch.enabled", havingValue = "true")
    public ApplicationContextFactory firstJobs() {
        return new GenericApplicationContextFactory(FirstModule.class);
    }

    @Bean
    @ConditionalOnProperty(value="second.batch.enabled", havingValue = "true")
    public ApplicationContextFactory secondJobs() {
        return new GenericApplicationContextFactory(SecondModule.class);
    }
    ...
}

and I have @Configuration classes, one for every Job defined respectively in base directories of modules. Everything works fine, but now I want to setup Spring Cloud Dataflow UI to have some basic monitoring of my Jobs.

The problem is, when I try to add @EnableTask annotation to this class BatchConfiguration, Spring is not associating job execution with task execution. It is only working, when I run tests (@SpringBatchTest).

I also tried to add @EnableTask annotation to FirstJobConfiguration class instead, and also add it to both BatchConfiguration and First|JobConfiguration, but with no effect. I also went through official documentation, but found nothing.

Is it possible to use Spring Cloud Task with modular Spring Batch ?

Thanks.

1 Answers1

0

The Spring Batch application can be converted into a Spring Cloud Task application and be managed using Spring Cloud Data Flow.

You should be able to use EnableTask in your SpringBoot application along with EnableBatchProcessing in your configuration.

Please see the SCDF sample which demonstrates this scenario.

Ilayaperumal Gopinathan
  • 4,099
  • 1
  • 13
  • 12
  • thank you for response and this is completely correct, but once i define jobs as modular, then they run each in its own child application context and then `Spring Cloud Task` cannot associate `Task` execution with `Batch` execution – Peter Bažík Feb 19 '20 at 10:23