memo

タイムアウト

Spring の HttpComponentsClientHttpRequestFactory で設定するタイムアウト

リトライ

独自例外ハンドラー例

private class MyHttpRequestRetryHandler extends DefaultHttpRequestRetryHandler {
    AshHttpRequestRetryHandler(final int retryCount, final boolean requestSentRetryEnabled) {
        super(retryCount, requestSentRetryEnabled);
    }
    @Override
    public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
        // SomeException はリトライしない
        if(exception instanceof SomeException) {
            System.out.println("Skip (no retry) SomeException.");
            return false;
        // HogeException は 10回リトライ
        } else if(exception instanceof HogeException && executionCount < 10 ) {
            System.out.println("HogeException: " + executionCount + ", " exception.toString());
            return true;
        }

        return super.retryRequest(exception, executionCount, context);
    }
}