Kafka Stream 学习笔记-1

本文探讨了Kafka Streams作为一款基于Kafka的数据流处理客户端库,如何结合Java/Scala应用的部署简易性和Kafka集群的服务器技术。它强调了客户端管理的灵活性,以及与Flink等其他流处理框架的对比。核心概念包括KStream、KTable和自定义StateStore,以及Stream计算中的Key处理和topic设计原则。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

定位

Kafka Streams is a client library for building applications and microservices, where the input and output data are stored in Kafka clusters. It combines the simplicity of writing and deploying standard Java and Scala applications on the client side with the benefits of Kafka’s server-side cluster technology.

kafka stream是一个客户端,因此扩容和HA都需要自行管理,优点是只依赖kafka,但也只能支持kafka,不支持其他消息系统。

官方与flink的比较:https://www.confluent.io/blog/apache-flink-apache-kafka-streams-comparison-guideline-users/
Dzone 与flink的 比较 https://dzone.com/articles/kafka-stream-kstream-vs-apache-flink

DSL 与Process API

DSL 相对高级、Process API更底层,一般使用DSL就可以,但定时操作只有Process API支持。

核心对象

  • KStream
  • KTable
  • KGlobalTable
  • State Store

State Store 可以自定义

各类自动生成的TOPIC

默认Stream 会创建很多topic 来支持repartition、group、map、job、changlog(state store)等操作。
中心top都会以APPLICATION_ID 开头,设置app id代码如下:

 Properties props = new Properties();
    props.put(StreamsConfig.APPLICATION_ID_CONFIG, "dev");

以下为示意
在这里插入图片描述
在这里插入图片描述

Key 和partition

Stream Topic之间的关联计算基本都基于Key,因此设计好Key很关键,当然也可以在stream计算过程中进行key转换。

如果多个topic的多partition,需要考虑通过selectKey(repartition )达到数据分布一致。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_40455124

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值