This topic describes how a Node.js client uses SDK for Node.js to connect to the default endpoint of Message Queue for Apache Kafka in a virtual private cloud (VPC) and send and subscribe to messages.
Prerequisites
- Install GCC
- Install Node.js.Notice The version of Node.js must be 4.0.0 or later.
- Install OpenSSL
Install the C++ library
Install the Node.js library
Preparations
Create a Message Queue for Apache Kafka configuration file named setting.js.
module.exports = {
'bootstrap_servers': ["kafka-ons-internet.aliyun.com:8080"],
'topic_name': 'xxx',
'consumer_id': 'xxx'
}
Parameter | Description |
---|---|
bootstrap_servers | The default endpoint. You can obtain the default endpoint in the Basic Information section of the Instance Details page in the Message Queue for Apache Kafka console. |
topic_name | The name of the topic. You can obtain the name of the topic on the Topics page in the Message Queue for Apache Kafka console. |
consumer_id | The name of the consumer group. You can obtain the name of the consumer group on the Consumer Groups page in the Message Queue for Apache Kafka console. |