Release Notes
Announcements
npmi rocketmq-client-nodejs
import { Producer } from 'rocketmq-client-nodejs';const producer = new Producer({endpoints: 'rmq-xxx.rocketmq.gz.qcloud.tencenttdmq.com:8080', // Tencent Cloud access point.sessionCredentials: {accessKey: 'yourAccessKey', // akaccessSecret: 'yourSecretKey', // sk}});await producer.startup();const receipt = await producer.send({topic: 'TopicTest', // Topic created in the console.body: Buffer.from(JSON.stringify({hello: 'rocketmq-client-nodejs world',now: Date(),})),});console.log(receipt);
Parameter | Description |
accessKey | Role token. You can copy the token from the AccessKey column on the Cluster Permissions page in the console. |
accessSecret | Role name. You can copy the role name from the SecretKey column on the Cluster Permissions page in the console. |
endpoints | Cluster access address. You can obtain the access address from the Access Information module on the Cluster Basic Information page in the console. |
topic | Topic name. You can copy the name from the Topic Management page in the console. |
import {SimpleConsumer } from 'rocketmq-client-nodejs';const simpleConsumer = new SimpleConsumer({endpoints: 'rmq-xxx.rocketmq.gz.qcloud.tencenttdmq.com:8080', // Tencent Cloud access point.sessionCredentials: {accessKey: 'yourAccessKey', // akaccessSecret: 'yourSecretKey', // sk},consumerGroup: 'nodejs-demo-group', // Consumer group.subscriptions: new Map().set('TopicTest', '*'),});await simpleConsumer.startup();const messages = await simpleConsumer.receive(20);console.log('got %d messages', messages.length);for (const message of messages) {console.log(message);console.log('body=%o', message.body.toString());await simpleConsumer.ack(message);}
Parameter | Description |
accessKey | Role token. You can copy the token from the AccessKey column on the Cluster Permissions page in the console. |
accessSecret | Role name. You can copy the role name from the SecretKey column on the Cluster Permissions page in the console. |
endpoints | Cluster access address. You can obtain the access address from the Access Information module on the Cluster Basic Information page in the console. |
consumerGroup | Consumer group name. You can copy the name from the Group Management page in the console. |
subscriptions | Topic name. You can copy the name from the Topic Management page in the console. |
フィードバック