title: How to Build a reliable client side rate limiter without dropping the messages?
body: <p>i am calling an external REST API Service from my java code, to prevent overloading that external API I need to ensure that not more than N calls are made to the service S per second. and need to make sure not a single function call is dropped</p>
  <p>my function will look like</p>
  <pre><code>public callXXXAPI(JSONObject message){
  
  formatData(message);
  
  //GET
  //REST API
  JSONObject response = getDataFromexternalAPI(message);
  
  contineNextProcess(response);
  </code></pre>
  <p>}</p>
  <p>This method callXXXAPI will be called asynchronously from Kafka consumer.</p>
  <p>i need to control the number of times external api getting called.</p>
  <p>i.e assume messages getting consumed in high speed in Kafka(1000000 messages per second)  but i need to call the external service 1000 (configurable) times per second. and i do not want to reject the other messages.</p>
  <p>i can not solve the problem with Google Guava's Rate Limiter, because when more number of messages getting consumed and more threads will be waiting for the next second and it will get overflowed. should i use any external JMS delay queue to solve this?  any better solution/ architecture for this problem?</p>