Kafka官方生产者和消费者脚本简单使用

问题

怎样使用Kafka官方生产者和消费者脚本进行消费生产和消费?这里假设已经下载了kafka官方文件,并已经解压.

生产者配置文件

producer_hr.properties

bootstrap.servers=10.xx.xx.xxx:9092,10.xx.xx.xxx:9092,10.xx.xx.xxx:9092
compression.type=none
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-256
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="myname" password="mypassword";

消费者配置文件

consumer_hr.properties

bootstrap.servers=10.xx.xx.xxx:9092,10.xx.xx.xxx:9092,10.xx.xx.xxx:9092
group.id=my_consume_group_id
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-256
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="myname" password="mypassword";

生产者脚本使用

./bin/kafka-console-producer.sh --bootstrap-server 10.xx.xx.xxx:9092,10.xx.xx.xxx:9092,10.xx.xx.xxx:9092 --producer.config ./config/producer_hr.properties --topic my_topic

消费者脚本使用

./bin/kafka-console-consumer.sh --bootstrap-server 10.xx.xx.xxx:9092,10.xx.xx.xxx:9092,10.xx.xx.xxx:9092 --consumer.config ./config/consumer_hr.properties --topic my_topic

总结

这就可以见到测试kafka对应topic了.

相关推荐

  1. Kafka官方生产者消费者脚本简单使用

    2023-12-09 21:40:09       61 阅读
  2. kafka生产者消费者

    2023-12-09 21:40:09       60 阅读
  3. Kafka建立生产者消费者

    2023-12-09 21:40:09       49 阅读
  4. kafka 生产者消费者设计思考

    2023-12-09 21:40:09       53 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-09 21:40:09       75 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-09 21:40:09       80 阅读
  3. 在Django里面运行非项目文件

    2023-12-09 21:40:09       64 阅读
  4. Python语言-面向对象

    2023-12-09 21:40:09       75 阅读

热门阅读

  1. LeetCode763. Partition Labels

    2023-12-09 21:40:09       38 阅读
  2. 大数据量快速数据库还原程序

    2023-12-09 21:40:09       52 阅读
  3. K-Means 算法详解

    2023-12-09 21:40:09       49 阅读
  4. linux 编译安装libzmq

    2023-12-09 21:40:09       51 阅读
  5. springboot基础(81):设置redis序列化器

    2023-12-09 21:40:09       55 阅读
  6. 写在FastAPI之旅之前

    2023-12-09 21:40:09       53 阅读
  7. ELK的日志解决方案

    2023-12-09 21:40:09       53 阅读
  8. 六部十层电梯论文

    2023-12-09 21:40:09       51 阅读