spring - 为什么不推荐使用 StreamListener
问题描述
我正在Spring Cloud Stream 3.1.2
使用KafkaStreams
. 编程模型有:
- 函数式编程
- 命令式编程
后者使用注解作为提供 Spring 以供使用的所有其他注解。但是,有人提到
从 3.1.0 版本的 binder 开始,我们建议对基于 Kafka Streams binder 的应用程序使用上述函数式编程模型。从 Spring Cloud Stream 的 3.1.0 开始,不推荐使用对 StreamListener 的支持。
因为我认为旧模型更具可读性(至少对我而言)。谁能解释为什么决定弃用它以支持函数式编程并将其删除?
解决方案
来自 Spring 博客文章 ( https://spring.io/blog/2019/10/17/spring-cloud-stream-functional-and-reactive ) 它说a functional programming model in Spring Cloud Stream (SCSt). It’s less code, less configuration. Most importantly, though, your code is completely decoupled and independent from the internals of SCSt
。这有利于使用 Project Reactor ( https://projectreactor.io/ )提供的事件流抽象(例如 Flux 和 Mono )。命令式函数会在每个单独的事件上触发,而响应式函数会触发一次。
推荐阅读
- python - 如何在 python 中获取和操作 API 的属性
- java - 未安装 Apk 编辑器输出应用程序
- javascript - 从 javascript 检查操作系统麦克风静音(MediaRecorder 的 track.muted 似乎不起作用)
- python - 我如何使用任何 Pyhton 包获取 Excel 单元格而不是公式中的值,以及如何使用相同的包从 excel 文件中读取
- reactjs - React JS-Second Route 标记在 App.js 中不起作用
- javascript - 如何根据路由有条件地显示组件
- c# - Ef Core 外键是唯一的,这不是我想要的
- postgresql - 如何查看用户在 PostgreSQL 中执行的查询?
- excel - 文本框日期(今天)“DD/MM/YYYY”在输入单元格“DD/MM/YYYY”时发生变化
- flutter - 将“MainAxisSize”设置为父小部件的最小值