Skip to content

It's unclear and confusing that using <skippable-exception-class> element. [BATCH-2541] #1061

Closed
@spring-projects-issues

Description

@spring-projects-issues

Mitsuyoshi Hasegawa opened BATCH-2541 and commented

I supporse that "<skippable-exception-class>" element does not satisfy users' purpose, and confuse them.

Details are shown below:

  1. We can't partition exceptions at each components surrounded <chunk> definition.

http://docs.spring.io/spring-batch/reference/htmlsingle/#configuringSkip

For examples above, it describes that if FileNotException occures, chunk processing is skipped.

But I want to change target exception to process each components, as below:

  • If exceptions occure in ItemReader, want to skip and obtain next item.
  • If exceptions occure in ItemProcessor, want to be "FAIL".

There are problems of poor usablity such as inability to change behaviors,
and I want to throw indivisual exception in each components.
such as ItemReaderException/ItemProcessorException (very simple examples)

  1. If skippable exception occures in ItemWriter, Chunk items implicitely skip and recovery as chunkSize = 1.

The behaviors of skip-and-recovery in ItemWriter is different from that
in ItemReader and ItemProcessor, obviously.

Since a <skippable-exception-class> element required to describe per <chunk> element,
I gave up adopting it because of unsuitable for my application desigin.

Details below:

  • When skippable-exception occcures in ItemReader, skip-and-recovery re-process the chunk from the beggining.
  • Chunk item is re-processed one by one, by FaultTolerantChunkProcessorはRecoveryCallback#scan().
  • Re-processing even skipped chunk item, and rollback if exception occures again.

This behavior is refered to this article:

https://blog.codecentric.de/en/2012/03/transactions-in-spring-batch-part-3-skip-and-retry/

To make matters worse, this behavior is undocumented in the Spring Batch-Reference Docs.
I am afraid that it takes a long time for them to try to find cause by "unexpected" behavior.

Thus, I want to describe this behavior in detail at Batch-Reference Docs.


Affects: 3.0.7

Reference URL: http://docs.spring.io/spring-batch/reference/htmlsingle/#configuringSkip

Referenced from: commits 6746cbd, f55d3bc, dc3fee5, ba4aa8c

Backported to: 4.3.0.M1, 4.2.1, 4.1.3, 4.0.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions