Reputation: 727
I'm using the Java MWS API from Amazon. Recently I received an Internal Error while requesting GetOrder
which was due to throttling limits.
How can I determine the throttling limits?
In the docs I see
Amazon MWS provides header values in each call response that show the hourly quota for the current operation; the number of calls remaining in tha quota; and the date and time when the quota will reset. For example:
x-mws-quota-max: 3600
x-mws-quota-remaining: 10
x-mws-quota-resetsOn: Wed, 06 Mar 2013 19:07:58 GMT
But I can't figure out how to get this metadata from the response. I expected them to be in the GetReportResponse
which I receive from calling getReport(GetReportRequest)
. It seems this data is not present. At least I wasn't able to get them.
But what I can see from the log output is:
org.apache.http.wire - << "x-mws-quota-max: 80.0"
org.apache.http.wire - << "x-mws-quota-remaining: 79.0"
org.apache.http.wire - << "x-mws-quota-resetsOn: 2016-01-23T09:19:00.000Z"
This data indeed seems to be present somewhere. How can I get this information from the response?
Upvotes: 3
Views: 1607
Reputation: 727
Meanwhile I hacked a bit around in the MWS client sources.
And it's really the case that the quota values are not exposed via the response nor via the WebServiceClient.
So I slightly modified the source code of MarketplaceWebServiceClient.java
to rememer the quota values for the last received response.
Somewhere around line 2100 it reads postResponse = httpClient.execute(method, httpContext);
and after that line I inserted
quotaMax = postResponse.getFirstHeader("x-mws-quota-max").getValue();
quotaRemaining = postResponse.getFirstHeader("x-mws-quota-remaining").getValue();
quotaResetsOn = postResponse.getFirstHeader("x-mws-quota-resetsOn").getValue();
This does the trick for me and I can get the quota values directly form the client.
Upvotes: 4