tencent cloud

Feedback

Apache Pulsar SDK for Node.js

Last updated: 2022-02-11 10:43:23

    Overview

    TDMQ for Pulsar 2.7.1 and above clusters already support Apache Pulsar SDK for Node.js. This document describes how to access the SDK.

    Prerequisites

    • Get the access address
      Copy the access address on the Cluster Management page in the TDMQ for Pulsar console.

    • Get the token
      Configure the role and permission as instructed in Role and Authentication and get the token of the role.

    Directions

    1. Install the Node.js client in your client environment as instructed in Pulsar Node.js client.
      $ npm install pulsar-client
      
    1. In the code for creating the Node.js client, configure the prepared access address and token.
      const Pulsar = require('pulsar-client');

      (async () => {
      const client = new Pulsar.Client({
      serviceUrl: 'http://*', // Replace with the access address (copied from the **Cluster Management** page in the console)
      authentication: Pulsar.NewAuthenticationToken("eyJh**"), // Replace with the token
      });

      await client.close();
      })();

    For how to use various features of the Apache Pulsar SDK for Node.js, see Pulsar Node.js client.

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support