获取亚马逊 MWS 节流限制

Getting Amazon MWS throttling limits

我正在使用亚马逊的 Java MWS API。最近我在请求 GetOrder 时收到 内部错误 ,这是由于节流限制造成的。

如何确定节流限制?

docs我看到了

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

但我不知道如何从响应中获取此元数据。我希望它们在我通过调用 getReport(GetReportRequest) 收到的 GetReportResponse 中。好像没有这个数据。至少我没能得到它们。

但是我从日志输出中看到的是:

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"

这个数据似乎确实存在于某处。如何从响应中获取此信息?

与此同时,我在 MWS client 来源中进行了一些修改。
事实上,配额值既没有通过响应也没有通过 WebServiceClient 公开。
所以我稍微修改了 MarketplaceWebServiceClient.java 的源代码以记住最后收到的响应的配额值。 在第 2100 行附近的某处,它显示为 postResponse = httpClient.execute(method, httpContext); 在那行之后我插入

quotaMax = postResponse.getFirstHeader("x-mws-quota-max").getValue();
quotaRemaining = postResponse.getFirstHeader("x-mws-quota-remaining").getValue();
quotaResetsOn = postResponse.getFirstHeader("x-mws-quota-resetsOn").getValue();

这对我有用,我可以直接从客户端获取配额值。