I need to limit the number of HTTP calls per second to max 10. This is as per the allowed quota.
Does HttpClient has some feature for this? Or any custom implementation would also do.
I need to limit the number of HTTP calls per second to max 10. This is as per the allowed quota.
Does HttpClient has some feature for this? Or any custom implementation would also do.
You might try the ScheduledThreadPoolExecutor.
From the javadoc:
You would simply use the
schedule
method and pass it aRunnable
, where theRunnable
makes your call via theHttpClient
. You could schedule yourRunnable
to run 10 times per second, or as needed. TheExecutor
will queue up your calls over theHttpClient
, and only run a max of 10 per second.