Spring batch jsr 352 skip-limit how to get unlimited default or set unlimited
Asked Answered
B

3

5

I am trying to figure out how to set an unlimited value for skip-limit with out just randomly defining a very large integer value.

The jsr 352 specifically states "The default is no limit." but I have not figure out how to get a default when actually defining a skippable exception.

I tried 0 and -1 but both fail the positive number validation that spring batch does on the step when creating the job. If the skip-limit attribute is not added when you have skippable exception defined it generates an error and does not start the job.

Am i misinterpreting what the specification is saying or is spring batch not implementing the jsr correctly in this instance. It definitely appears on the surface that skip-limit should have some means of defaulting to an unlimited value.

Boutique answered 24/9, 2015 at 20:19 Comment(0)
M
7

Your could do something like:

public class ItemSkipPolicy implements SkipPolicy {

public boolean shouldSkip(final Throwable t, final int skipCount) throws SkipLimitExceededException {
    return true;
}

and use the skip policy instead of the skipLimit

.faultTolerant().skipPolicy(new ItemSkipPolicy()).skip(RuntimeException.class)

hopfully this helps if someone else sees this page

Monoceros answered 27/4, 2017 at 11:6 Comment(1)
There is into spring batch package a Implementation of the SkipPolicy interface that will always return that an item should be skipped. .faultTolerant().skipPolicy(new AlwaysSkipItemSkipPolicy()).skip(RuntimeException.class)Lamination
H
2

From the JSR :

skip-limit : Specifies the number of exceptions a step will skip if any configured skippable exceptions are thrown by chunk processing. It must be a valid XML integer value. It is an optional attribute. The default is no limit.

If you respect the JSR in spring batch you should have this behavior. if you will don't follow the JSR, you face the BATCH-2443.

Hamstring answered 2/2, 2017 at 14:29 Comment(1)
using faultTolerant().skip(Exception.class) without specifying the skipLimit attribute means that the default value is 0: org.springframework.batch.core.step.skip.SkipLimitExceededException: Skip limit of '0' exceededIrwin
N
1

The skip-limit is an integer, so as far as you dont exceed the max value, you could for this as a value: #{T(java.lang.Integer).MAX_VALUE}. Not providing a skip limit in your step configuration would raise an error by Spring batch :

The field 'skippable-exception-classes' is not permitted on the step [stepName] because there is no 'skip-limit'.
Nonsuit answered 4/5, 2020 at 10:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.