开发者

Java exception handling with retry [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 8 years ago.

Improve this question 开发者_JS百科

Working on a small internet application, I need to deal with a service out-of-service situation. What is a good approach of retry after an exception?


The simplest solution (though maybe not the best) would be to return an error page to the user (with status 503: Service Unavailable), and tell him he should try again in a few seconds.


Depends on how long your application will be out of service but I will go with one of those :
- if the interruption is short less than one minute, loop and try to call the function/service/ ....
- if the interruption could be longer, you could use a JavaScript routine that would
automatically refresh the page ... every 60s
- As Eran Zimmerman's answer, display an error page and advice the user to try again later


You don't want to beat your application to death with repeated retries. Returning an error page is not that bad an option. If you must retry (you have some flaky service where you can't cache the results) then use a backing-off approach where with each retry you double the time until the next try.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜