定位
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 )达到数据分布一致。