为什么streamlistener不受欢迎

3npbholx  于 2021-07-13  发布在  Java
关注(0)|答案(1)|浏览(336)

我正在使用 Spring Cloud Stream 3.1.2 为了 KafkaStreams . 编程模型包括:
函数式程序设计
命令式程序设计
后者使用的注解与spring提供的所有其他注解一样。但是,有人提到
从binder的3.1.0版本开始,我们建议对基于kafka streams binder的应用程序使用上述函数式编程模型。从SpringCloudStream的3.1.0开始,就不赞成对streamlistener的支持。
因为我认为旧的模型更具可读性(至少对我来说)。有人能解释一下为什么它会被弃用而支持函数式编程吗?它会被删除吗?

y4ekin9u

y4ekin9u1#

来自 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 . 这有利于使用projectreactor提供的事件流抽象(如flux和mono)(https://projectreactor.io/). 命令函数在每个单独的事件上触发,而React函数只触发一次。

相关问题