Skip to content

Unable to register an annotation-based StepExecutionListener in a fault-tolerant step #4137

Closed
@fmbenhassine

Description

@fmbenhassine

As of v4.3.6, it is not possible to register an annotation-based StepExecutionListener in a fault-tolerant step. The following snippet does not compile:

FaultTolerantStepBuilder builder = new StepBuilder("step")
   .repository(jobRepository)
   .transactionManager(transactionManager)
   .chunk(5)
   .reader(new DummyItemReader()) 
   .writer(new DummyItemWriter())
   .faultTolerant()
   .listener(new AnnotationBasedStepExecutionListener()); // compilation error here

This is because org.springframework.batch.core.step.builder.FaultTolerantStepBuilder#listener(java.lang.Object) returns SimpleStepBuilder while it should return FaultTolerantStepBuilder. Note how all other methods that are related to listener registration in the FaultTolerantStepBuilder class return FaultTolerantStepBuilder and not SimpleStepBuilder.


Reference: https://stackoverflow.com/questions/52167498

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions