java - Gmail API Users.Messages.get throws User Rate Limit Exceeded -


Trying to use the RESTFul API from Gmail and I'm getting this error: the user rate limit exceeded

However, I do throttling (in 5 seconds and not 5 times, when Google says that there are no 25 calls in 1 second) and even when I'm getting an exception and there is a lot more, I still I am implementing this. This exception is still happening

Therefore, what can be the problem here?

Thanks

There is a well defined quota for Google API, here There is one for Gmail:

There is a small utility class to handle quota (for single thread, thread implementation is slightly more complicated):

  public Range of APLRTimeters {Private long-time selective; Private Final Quaterifier Second; Private int quata remanning; Public ApilRateLimiter (last full quotaPerSecond) {this.quotaPerSecond = quotaPerSecond; This.quotaRemaining = quotaPerSecond; This.timeSliceEnd = System.currentTimeMillis () + 1_000L; } Approval of obstruction of Public Zero Reserve (final quota reserved for quota) {if (quota reserve & quot; quotaappers second) {new illegal archives ("Reservation will never be successful because quota requested from second to second is more"); } Last Long Current Time = System TimeTime (); If (current time> date = time remaining) {this.timeSliceEnd = Current time + 1_000L; This.quotaRemaining = quotaPerSecond-quotaReserved; } And if (quota reserved  

and definition for Gmail quota:

  Public interface Gmail applications {int QUOTA_PER_SECOND = 250; Int DRAFTS_CREATE = 10; Int DRAFTS_DELETE = 10; Int DRAFTS_GET = 5; Int DRAFTS_LIST = 5; Int DRAFTS_SEND = 100; Int DRAFTS_UPDATE = 15; Int GETPROFILE = 1; Int HISTORY_LIST = 2; Int LABELS_CREATE = 5; Int LABELS_DELETE = 5; Int LABELS_GET = 1; Int LABELS_LIST = 1; Int LABELS_UPDATE = 5; Int MESSAGES_ATTACHMENTS_GET = 5; Int MESSAGES_BATCHDELETE = 50; Int MESSAGES_DELETE = 10; Int MESSAGES_GET = 5; Int MESSAGES_IMPORT = 100; Int MESSAGES_INSERT = 25; Int MESSAGES_LIST = 5; Int MESSAGES_MODIFY = 5; Int MESSAGES_SEND = 100; Int MESSAGES_TRASH = 5; Int MESSAGES_UNTRASH = 5; Int STOP = 50; Int THREADS_DELETE = 20; Int THREADS_GET = 10; Int THREADS_LIST = 10; Int THREADS_MODIFY = 10; Int THREADS_TRASH = 10; Int THREADS_UNTRASH = 10; Int Watch = 100; }  

You use it like this:

  this.apiRateLimiter = New Apparatite Limiter (GmailApiLimits.QUOTA_PER_SECOND); ... apiRateLimiter.reserve (GmailApiLimits.MESSAGES_LIST); .. GmailApi.users () Message () list ("me") ... executed (); ... apiRateLimiter.reserve (GmailApiLimits.MESSAGES_GET); GmailApi.users () message (). (Execute "me" ...) ... ...  

Actually, you call reserved () before you get a Gmail Call APIs. If the quotas are left for the second, the reserve returns are OK, otherwise it sleeps until the other ends.


Comments

Popular posts from this blog

Folder list php -

GO: Serve static pages -

python - Why can't I destroy my StaticText in wxPython? -