当前位置: 首页 > news >正文

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了.

http://www.lryc.cn/news/239680.html

相关文章:

  • 如何开发干洗店用的小程序
  • 回溯算法详解
  • 边云协同架构设计
  • 【c++】——类和对象(下) 万字解答疑惑
  • Appium自动化测试:通过appium的inspector功能无法启动app的原因
  • 易点易动设备管理系统:提升企业设备维修效率的工具
  • JVM中判断对象是否需要回收的方法
  • t检验(连续变量)和卡方检验(分类变量)
  • PDF转Word,1行Python代码就够了,免费用
  • 【开源】基于Vue和SpringBoot的智能教学资源库系统
  • 『亚马逊云科技产品测评』活动征文|通过Lightsail搭建个人笔记
  • 基于JavaWeb+SSM+Vue家庭记账本微信小程序系统的设计和实现
  • 十二、h.264解码
  • springboot前后端分离项目配置https接口(ssl证书)
  • 智能小车速通版——手把手教程
  • 【C++】vector的介绍与使用
  • 【libGDX】使用Mesh绘制圆形
  • 一个测试驱动的Spring Boot应用程序开发
  • 简单几步,借助Aapose.Cells将 Excel XLS 转换为PPT
  • CSS特效016:天窗扬起合上的效果
  • 基于SSM的济南旅游网站设计与实现
  • 【ArrayList是如何扩容(ArrayList、LinkedList、与Vector的区别)】
  • STM32_3(GPIO)
  • 【技巧】PDF文件如何编辑?
  • AR道具特效制作工具
  • 鸿蒙4.0开发笔记之DevEco Studio页面操作router的pushUrl页面跳转与back返回上一页(五)
  • 20个CSS函数-释放设计创造力和响应能力
  • Dubbo从入门到上天系列第十八篇:Dubbo引入注册中心简介以及DubboAdmin简要介绍,为后续详解Dubbo各种注册中心做铺垫!
  • CentOS8安装MySQL
  • Java集合拓展01