exponential backoff support?

82 views
Skip to first unread message

Wilson MacGyver

unread,
Dec 3, 2012, 4:30:31 PM12/3/12
to google-api-...@googlegroups.com
Hi,

I noticed google-http-java-client has support for exponential backoff.

http://code.google.com/p/google-http-java-client/wiki/ExponentialBackoff

does google api java client make use of it? if so, how do I enable it?

Thanks

--
Omnem crede diem tibi diluxisse supremum.

Jason Hall

unread,
Dec 3, 2012, 11:17:03 PM12/3/12
to google-api-...@googlegroups.com
You can set the backoff policy on any HttpRequest, such as:

ResponseObj obj = service.resource().method()
    .setBackOffPolicy(...)
    .execute();

Or, if you want to use the exponential back-off policy for all requests, set it up in the HttpRequestInitializer when you set up the service:

Service service = new Service(httpTransport, jsonFactory, new HttpRequestInitializer() {
    @Override
    public void initialize(HttpRequest req) {
      req.setBackOffPolicy(...);
      // Do any other initialization here, such as using a Credential to make authorized requests.
    }
  });
service.resource().method().execute(); // <-- this request will use the back-off policy you set

- Jason

Wilson MacGyver

unread,
Dec 5, 2012, 1:18:45 PM12/5/12
to google-api-...@googlegroups.com
Thanks, I will try that.
Reply all
Reply to author
Forward
0 new messages