Set up Pulsar Node.js client
To set up Java client library in Pulsar, complete the following steps.
Step 1: Install Node.js client library
Install the pulsar-client
library via npm:
npm install pulsar-client
For more information, see README.
This library only works in Node.js 10.x or later versions because it uses the node-addon-api
module.
Step 2: Connect to Pulsar cluster
To connect to Pulsar using client libraries, you need to specify a Pulsar protocol URL.
You can assign Pulsar protocol URLs to specific clusters and use the pulsar
scheme. The following is an example of localhost
with the default port 6650
:
pulsar://localhost:6650
If you have multiple brokers, separate IP:port
by commas:
pulsar://localhost:6550,localhost:6651,localhost:6652
If you use mTLS authentication, add +ssl
in the scheme:
pulsar+ssl://pulsar.us-west.example.com:6651