Skip to content

Timeout and maximum retries

Ahmad K. Bawaneh edited this page Mar 16, 2020 · 3 revisions

Timeout and maximum retries

Sometimes requests might timeout due to network latency or other reasons and we dont want our requests to fail directly but rather want to retry several times before we end up failing the request. in domino-rest we can use the @Retries annotation to define a timeout with maximum retries count.

@RequestFactory
public interface MoviesService {

    @Path("library/movies/:movieName")
    @GET
    Movie getMovieByName(@PathParam("movieName") String movieName);

    @Path("library/movies")
    @GET
    List<Movie> listMovies();

    @Path("library/movies/:name")
    @PUT
    @SuccessCodes({200})
    @Retries(timeout=3000, maxRetries=5)
    void updateMovie(@BeanParam @RequestBody Movie movie);
}

the updateMovie will timeout if the response not returned within 3000 milliseconds but will try 5 times before it actually fail.

we can also set a global timeout and max retries in a global interceptor which is documented in other parts of this wiki.