Initialize Node.js client

To interact with Pulsar, you first need a client object. You can create a client instance using a new operator and the Client method, passing in a client options object.

Here is an example:

  1. const Pulsar = require('pulsar-client');
  2. (async () => {
  3. const client = new Pulsar.Client({
  4. serviceUrl: 'pulsar://localhost:6650',
  5. });
  6. await client.close();
  7. })();

For a complete list of client configurations, see here.