🍣Component retry
LiteFLow supports retry of components
# Global retry
If you need to retry globally, you need to do the following configuration:
liteflow.retry-count=3
This means that if the component throws any exception, it will retry 3 times, and if the exception still occurs after 3 times, the whole chain ends.
The chain will continue in the following cases:
If the component overrides isContinueOnError
, set to true, the process will continue.
For asynchronous processes, if ignoreError
is configured on WHEN
to be true (default is false), the next different parallel group will continue. For the definition and use of ignoreError
, you can check the Parallel mode chapter.
# Single component retry
LiteFlow also provides a retry feature that specifies Exception based on a single component. LiteFlow has provided the @LiteflowRetry
annotation since 2.6.0
You can annotate specific components:
@LiteflowComponent("c")
@LiteflowRetry(5)
public class CCmp extends NodeComponent {
@Override
public void process() {
//do your biz
}
}
This means that if this component throws any exception, it will retry up to 5 times. If the 5th retry is unsuccessful, it will really throw your business exception
One or more exceptions can also be specified on this annotation:
@LiteflowComponent("e")
@LiteflowRetry(retry = 5, forExceptions = {NullPointerException.class,IllegalArgumentException.class})
public class ECmp extends NodeComponent {
@Override
public void process() {
//do your biz
}
}
This means that if the exception thrown by this component is NullPointerException
or IllegalArgumentException
(or subclasses of these two Exception classes), it will make up to 5 attempts, and the last attempt is unsuccessful, it will be true Throw an exception.
# Mixed definition
If the above two modes are both defined, the retry configuration of a single component takes precedence. If not, take the global configuration.