Kafka-NodeJS-Client-Test:Kafka NodeJS客户端测试

  • l5_359914
    了解作者
  • 4.3KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-20 05:42
    上传日期
Kafka NodeJS客户端测试 简而言之,所有需要的代码都能正常工作是一个简单的起点。 它使用来自的库以及它们提供的示例的混合。 该代码仅用于测试目的。 Kafka安装使用以下教程进行: : 创建主题 ./kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 2 --topic KAFKAJSTests 消费 以这种方式解雇使用者(至多为您拥有的分区数): KAFKACLUSTER=localhost node consumer.js [topic] [groupId] [partition] 所有参数都有默认值,因此您可以简单地运行: node consumer.js 它将连接到名为kafka-node-group的组中的本地主机
Kafka-NodeJS-Client-Test-master.zip
  • Kafka-NodeJS-Client-Test-master
  • producer.js
    1.6KB
  • LICENSE
    1.1KB
  • README.md
    1.3KB
  • .gitignore
    526B
  • consumer.js
    1.4KB
  • package.json
    288B
内容介绍
# Kafka NodeJS Client Test Its a simple start point to have all needed code working in a nutshell. It uses the lib from https://github.com/SOHU-Co/kafka-node, and a mix of their provided examples. This code was made only for testing purposes. Kafka installation was made using this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-apache-kafka-on-ubuntu-14-04 ### To Create a Topic ``` ./kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 2 --topic KAFKAJSTests ``` ### To Consume Fire consumers (at most to the number of partitions you have) this way: ``` KAFKACLUSTER=localhost node consumer.js [topic] [groupId] [partition] ``` All parameters have default values, so you can simply run: ``` node consumer.js ``` It will connect to localhost, topic TutorialTopic, partition 0 in a group called kafka-node-group, and start a consuming loop. ### To Produce Fire producers this way: ``` KAFKACLUSTER=localhost node producer.js [topic] [partition] [message_key] [message] ``` All parameters have default values, so you can simply run: ``` node producer.js ``` It will connect to localhost, topic TutorialTopic, partition 0. Will send a message with a key of 'some_key', and a message 'some_message', then will get back to shell prompt.
评论
    相关推荐