title: kafka consumer and async handler
body: <p>I have a node.js app with a Kafka subscriber.
  The subscription handler use "fetch" to call a remote REST API (await fetch(...)).</p>
  
  <p>I try to handle a high frequency of messages, the REST calls failed because of the overload of the remote server.</p>
  
  <p>The overload happen because the subscriber hanler is asynchronous.</p>
  
  <p>My question is :
  Is there is a way to insure that the async handlers are serialized, so there is no simultaneous calls to the remote API server ?</p>
  
  <p>Chris: 
  I am using kafka-node</p>
  
  <p>Here is a code sample:</p>
  
  <pre><code>const consumer = new Consumer(this.client, [{ topic: topicKey}]);
  consumer.on('message', function (message) {
    handleMessage(message)
  });
  
  async function handleMessage(message) {
     ... decode the message
  
    // Send to the Remote server using a REST call
  
    //=&gt; the task is suspended, waiting for the IO, so, meantime, the next message
    //   is processed, and I flood the remote server of POST requests.
    await fetch(...);
  }
  </code></pre>
  
  <p>Thanks.</p>