Java 在AsyncHttprespons中使用回退以避免;“请求太多”;错误

Java 在AsyncHttprespons中使用回退以避免;“请求太多”;错误,java,android,android-asynctask,httpclient,exponential-backoff,Java,Android,Android Asynctask,Httpclient,Exponential Backoff,我有一个从GoogleBooksAPI读取一些数据的应用程序 我使用AsyncHttpRequest获取数据 我开始出现以下错误: 2021-04-22 20:38:18.083 24736-24736/com.xx.yy V/AsyncHttpRH: Progress 538 from 1 (53800%) 2021-04-22 20:38:18.083 24736-24736/com.xx.yy I/chatty: uid=10089(com.xx.yy) identical 1 line

我有一个从GoogleBooksAPI读取一些数据的应用程序

我使用
AsyncHttpRequest
获取数据

我开始出现以下错误:

2021-04-22 20:38:18.083 24736-24736/com.xx.yy V/AsyncHttpRH: Progress 538 from 1 (53800%)
2021-04-22 20:38:18.083 24736-24736/com.xx.yy I/chatty: uid=10089(com.xx.yy) identical 1 line
2021-04-22 20:38:18.086 24736-24736/com.xx.yy V/AsyncHttpRH: Progress 538 from 1 (53800%)
2021-04-22 20:38:18.088 24736-24736/com.xx.yy W/JsonHttpRH: onFailure(int, Header[], Throwable, JSONObject) was not overriden, but callback was received
    cz.msebera.android.httpclient.client.HttpResponseException: Too Many Requests
        at com.loopj.android.http.AsyncHttpResponseHandler.sendResponseMessage(AsyncHttpResponseHandler.java:446)
        at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:160)
        at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
        at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
2021-04-22 20:38:18.101 24736-24736/com.xx.yy I/chatty: uid=10089(com.xx.yy) identical 5 lines
2021-04-22 20:38:18.101 24736-24736/com.xx.yy W/JsonHttpRH: onFailure(int, Header[], Throwable, JSONObject) was not overriden, but callback was received
    cz.msebera.android.httpclient.client.HttpResponseException: Too Many Requests
        at com.loopj.android.http.AsyncHttpResponseHandler.sendResponseMessage(AsyncHttpResponseHandler.java:446)
        at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:160)
        at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
        at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
2021-04-22 20:38:18.135 24736-24736/com.xx.yy V/AsyncHttpRH: Progress 538 from 1 (53800%)
2021-04-22 20:38:18.155 24736-24736/com.xx.yy W/JsonHttpRH: onFailure(int, Header[], Throwable, JSONObject) was not overriden, but callback was received
    cz.msebera.android.httpclient.client.HttpResponseException: Too Many Requests
        at com.loopj.android.http.AsyncHttpResponseHandler.sendResponseMessage(AsyncHttpResponseHandler.java:446)
        at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:160)
        at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
        at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
我不确定是什么原因造成的,因为我读到使用指数衰减可能会有所帮助

我的AsyncHttpClient正在使用loopj库,该库具有:

BackoffManager b = new BackoffManager() {
    @Override
    public void backOff(HttpRoute route) {
        
    }

    @Override
    public void probe(HttpRoute route) {

    }
}
但我不知道如何在课堂上使用它:

public void getBooks(final String query, JsonHttpResponseHandler handler) {
    try {
        client.get( API_BASE_URL + URLEncoder.encode( query, "utf-8" ), handler );
    } catch (UnsupportedEncodingException ignored) {

    }
}
在我的案例中,有没有关于如何实施这一策略的建议

多谢各位