My step is supposed to write a ton of items to DB table with unique index on few columns, therefore some items will produce DataIntegrityViolationException. I want to make my step faultTolerant to that without setting chunk size to 1. The following configuration unfortunately does not work as expected and just skip whole chunk when exception occurs, probably I misread something here:
stepBuilderFactory.get("someStep")
.<InputDto, Entity>chunk(100)
.reader(reader())
.processor(processor())
.writer(repositoryItemWriter(repository())
.faultTolerant()
.skipLimit(Integer.MAX_VALUE)
.skip(DataIntegrityViolationException.class)
.noRollback(DataIntegrityViolationException.class)
.processorNonTransactional()
.build();
Also as mentioned here behaviour of exception skip in chunk sounds a bit expensively, doesn't it? What is the most efficent way to deal with it then? Select for uniqueness check before insert doesn't look great either.