How to implement a retry mechanism in jersey-client java -


i doing http rest api calls using jersey-client. want retry failure request. if return error code not 200 want retry again few times. how can using jersey client

for implementing retries in situation, check out failsafe:

retrypolicy retrypolicy = new retrypolicy()   .retryif((clientresponse response) -> response.getstatus() != 200)   .withdelay(1, timeunit.seconds)   .withmaxretries(3);  failsafe.with(retrypolicy).get(() -> webresource.post(clientresponse.class, input)); 

this example retries if response status != 200, 3 times, 1 second delay between retries.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -