Compare retries already spent against a fixed budget and choose a retry, hold, or abort action.

remaining budget The remaining budget is derived once so each action variant has a single visible driver.

Retry Budget Remediation Report

retriesUsed
RetryBudgetRemediationReport.java
Replay: real traced execution (multi-file project)
public class RetryBudgetRemediationReport {
    public static void main(String[] args) {
        int retriesUsed = 1;
        int retryBudget = 4;
        int remaining = retryBudget - retriesUsed;
        String action = "retry";

        if (remaining <= 1) {
            action = "hold";
        }
        if (remaining <= 0) {
            action = "abort";
        }

        System.out.println("used=" + retriesUsed + " remaining=" + remaining + " action=" + action);
    }
}
public class RetryBudgetRemediationReport {
    public static void main(String[] args) {
        int retriesUsed = 3;
        int retryBudget = 4;
        int remaining = retryBudget - retriesUsed;
        String action = "retry";

        if (remaining <= 1) {
            action = "hold";
        }
        if (remaining <= 0) {
            action = "abort";
        }

        System.out.println("used=" + retriesUsed + " remaining=" + remaining + " action=" + action);
    }
}
public class RetryBudgetRemediationReport {
    public static void main(String[] args) {
        int retriesUsed = 5;
        int retryBudget = 4;
        int remaining = retryBudget - retriesUsed;
        String action = "retry";

        if (remaining <= 1) {
            action = "hold";
        }
        if (remaining <= 0) {
            action = "abort";
        }

        System.out.println("used=" + retriesUsed + " remaining=" + remaining + " action=" + action);
    }
}
  1. retriesUsed ← 1, retryBudget ← 4, remaining ← 3, action ← retry

    1public class RetryBudgetRemediationReport {2    public static void main(String[] args) {3        int retriesUsed→ 1 = 1;  //@retriesUsed=3, 54        int retryBudget→ 4 = 4;5        int remaining→ 3 = retryBudget4 - retriesUsed1;6        String action→ retry = "retry";78        if (remaining <= 1) {9            action = "hold";10        }11        if (remaining <= 0) {12            action = "abort";13        }1415        System.out.println("used=" + retriesUsed1 + " remaining=" + remaining3 + " action=" + actionretry);16    }
    outputused=1 remaining=3 action=retry
  1. retriesUsed ← 3, retryBudget ← 4, remaining ← 1, action ← retry

    1public class RetryBudgetRemediationReport {2    public static void main(String[] args) {3        int retriesUsed→ 3 = 3;4        int retryBudget→ 4 = 4;5        int remaining→ 1 = retryBudget4 - retriesUsed3;6        String action→ retry = "retry";
  2. action ← hold

    8if (remaining1 <= 1) {9    action→ hold = "hold";10}
  3. System.out.println("used=" + retriesUsed + " remaining=" + remaining +…

    15    System.out.println("used=" + retriesUsed3 + " remaining=" + remaining1 + " action=" + actionhold);16}
    outputused=3 remaining=1 action=hold
  1. retriesUsed ← 5, retryBudget ← 4, remaining ← -1, action ← retry

    1public class RetryBudgetRemediationReport {2    public static void main(String[] args) {3        int retriesUsed→ 5 = 5;4        int retryBudget→ 4 = 4;5        int remaining→ -1 = retryBudget4 - retriesUsed5;6        String action→ retry = "retry";
  2. action ← hold

    8if (remaining-1 <= 1) {9    action→ hold = "hold";10}
  3. action ← abort

    10}11if (remaining-1 <= 0) {12    action→ abort = "abort";13}
  4. System.out.println("used=" + retriesUsed + " remaining=" + remaining +…

    15    System.out.println("used=" + retriesUsed5 + " remaining=" + remaining-1 + " action=" + actionabort);16}
    outputused=5 remaining=-1 action=abort