Go to next step if retries are exhausted
Exception strategy - go to next step if exhausted retrying
In case you want your step not to stop in the flow with the red icon but to go to the next step where you properly route it, apply the following strategy.
<?xml version="1.0" encoding="UTF-8"?>
<config>
<var-def name="exhaustedOfRetrying">
false
</var-def>
<var-def name="lastException">
</var-def>
<var-def name="lastExceptionTrace">
</var-def>
<try>
<body>
<script>
<![CDATA[ throw RuntimeException("Something bad happened"); ]]>
</script>
</body>
<catch>
<script>
<![CDATA[
int processingAttempts = item.getWrappedObject().getSubmission().getAwsHit().getProcessingAttempts();
Integer maxAttempts = item.getWrappedObject().getRun().getMaxProcessingCount();
if (maxAttempts == null) {
// Should read "${application.maximum.processing.count}" property instead.
maxAttempts = 10;
}
]]>
</script>
<case>
<if condition="${processingAttempts >= maxAttempts}">
<var-def name="exhaustedOfRetrying">
true
</var-def>
<var-def name="lastException">
<var name="_exception_message"/>
</var-def>
<var-def name="lastExceptionTrace">
<var name="_exception_stacktrace"/>
</var-def>
</if>
<else>
<release time-in-seconds="60"/><!-- Optional. To have a pause before next attempt -->
<!-- Re-throwing to let it count for failure. -->
<script>
<![CDATA[ throw _exception.getWrappedObject().getCause(); ]]>
</script>
</else>
</case>
</catch>
</try>
<export include-original-data="true">
<single-column name="step_execution_failed">
<var name="exhaustedOfRetrying"/>
</single-column>
<single-column name="step_execution_exception_message">
<var name="lastException"/>
</single-column>
<single-column name="step_execution_exception_trace">
<var name="lastExceptionTrace"/>
</single-column>
</export>
</config>