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

企业建站报价专业网站制作定制

企业建站报价,专业网站制作定制,虚拟主机管理,北京网站的制作设计1、官网下载最新版本的kafka,里面已经集成zookeeper。直接解压到D盘 2、配置文件修改,config目录下面的zookeeper.properties. 设置zookeeper数据目录 dataDirD:/kafka_2.12-3.6.0/tmp/zookeeper 3、修改kafka的配置文件server.properties. 主要修…

1、官网下载最新版本的kafka,里面已经集成zookeeper。直接解压到D盘

2、配置文件修改,config目录下面的zookeeper.properties.   设置zookeeper数据目录

dataDir=D:/kafka_2.12-3.6.0/tmp/zookeeper

3、修改kafka的配置文件server.properties.   主要修改内容如下:

zookeeper.connect=localhost:2181

log.dirs=D:\\kafka_2.12-3.6.0\\logs

listeners=PLAINTEXT://localhost:9092

其他默认即可。

4、修改完成后进入bin目录:启动zookeeper和kafka,命令如下

zookeeper-server-start.bat ../../config/zookeeper.properties

kafka-server-start.bat ../../config/server.properties

5、命令行创建topic,命令如下:

kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic hello

6、创建生产者和消费者,测试。生产者输入消息,消费者就会收到相应的消息了 

kafka-console-producer.bat --broker-list localhost:9092 --topic hello

kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic hello--from-beginning

7、创建springboot工程,测试

引入依赖:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>

8、yml文件配置kafka

spring:
kafka:
bootstrap-servers: localhost:9092
producer:
acks: 1
retries: 3
batch-size: 16384
properties:
linger:
ms: 0
buffer-memory: 33554432
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.common.serialization.StringSerializer
consumer:
group-id: helloGroup
enable-auto-commit: false
auto-commit-interval: 1000
auto-offset-reset: latest
properties:
request:
timeout:
ms: 18000
session:
timeout:
ms: 12000
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer

9、使用springboot    KafkaTemplate发送消息

@RequestMapping(value = "/sendMessage", method = RequestMethod.GET)
public String sendMessage(String message) {
kafkaTemplate.send("hello", message);

return "发送成功~";
}

10、消息消费,


@KafkaListener(topics = "hello")
public void receiveMessage(ConsumerRecord<String, String> record) {
String topic = record.topic();
long offset = record.offset();
int partition = record.partition();
String message = record.value();

System.out.println("topic = " + topic);
System.out.println("offset = " + offset);
System.out.println("partition = " + partition);
System.out.println("message = " + message);
}

http://www.yayakq.cn/news/38332/

相关文章:

  • 如何写一份企业网站建设方案十大外包公司
  • 如何上传到自己的网站优化方案范文
  • 四川大学毕业设计网站台州平面设计公司
  • wordpress自动生成缩略图西安官网seo价格
  • 中国移动视频网站建设php网站转移
  • asp网站空间申请视频剪辑培训比较有名的学校
  • 深圳外贸电商网站建设西宁休闲娱乐场所
  • 泉州建设人才网站wordpress添加
  • 郴州做网站的公司企业画册设计模板
  • 松原建设网站平台建设包括哪些方面
  • 咸阳做网站直播网站开发教程
  • 安徽手机版建站系统shopify官网
  • 网站开发项目需要哪些人员策划师备案域名回收
  • 网站建设与运营 就业你认为的网络营销是什么
  • 域名注册的网站都有哪些网站软件app
  • 高校网站群建设方案进一步推进网站建设
  • 免费一级域名注册网站h5页面制作效果图
  • 如何做网站模板深圳室内设计公司排行
  • 网站建设设计要点深圳网页制作与网站建设地址
  • gta5资产网站正在建设珠海市工程造价信息网
  • 网站报备流程门户网站的发展趋势
  • 随州有哪些网站建设的公司如何创建div做网站
  • 申请域名的网站网站建设OA系统开发
  • 做网站需要什么技术人员对电子商务网站建设与维护的总结
  • 浅谈博星卓越网站建设单页建站系统
  • 焦作网站建设哪家好网站建优化
  • 广州专业的网站推广工具中国建筑集团有限公司电话
  • 网页制作与网站建设项目教程上海最专业的网站建设公司排名
  • 南宁市做网站电脑网站开发手机上可以打开吗
  • 网站建设 太原新增专业建设规划