Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Retries Java

int retries = 0;
public CompletableFuture<Result> executeActionAsync() {

    // Execute the action async and get the future
    CompletableFuture<Result> f = executeMycustomActionHere();

    // If the future completes with exception:
    f.exceptionally(ex -> {
        retries++; // Increment the retry count
        if (retries < MAX_RETRIES)
            return executeActionAsync();  // <--- Submit one more time

        // Abort with a null value
        return null;
    });

    // Return the future    
    return f;
}
Comment

Retries Java

private static RetryPolicy retryPolicy = new RetryPolicy()
    .withMaxRetries(MAX_RETRIES);

public CompletableFuture<Result> executeActionAsync() {
    return Failsafe.with(retryPolicy)
        .with(executor)
        .withFallback(null)
        .future(this::executeMycustomActionHere);
}
Comment

PREVIOUS NEXT
Code Example
Java :: Algorithms - count 
Java :: bukkit shutdown 
Java :: transpose array in java 
Java :: Java program to find which department has highest placement program 
Java :: tipe data c++ 
Java :: infinity constant in java 
Java :: java see you next happy year 
Java :: 710*12 
Java :: java to exe 
Java :: Java throws clause 
Java :: bipredicate in java 
Java :: how to check that letter is not a number and is repeating or not in a sentence in java 
Java :: number output swing java 
Java :: IMEI DEVISE ANDROID JAVA 
Java :: how to get visibility of element android 
Java :: how to create an indefilite loop in java 
Java :: print java object inherited classes 
Java :: function name in java 
Java :: api to accept a csv file spring boot 
Java :: tree algorithm example 
Java :: read properties file outside jar java 
Java :: tomcat allow remote access to manager 
Java :: how to print multi dimension array in java using for each loop 
Java :: android code get arrayList index 
Java :: get selected text in java 
Java :: Double And Char In Java 
Java :: Java instanceof in Interface 
Java :: JAXRS EXCEPTION MAPPER 
Java :: Read array of characters from space separated values in java 
Java :: Java program pattern program to triangle using 100 numbers 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =