为什么不推荐使用 StreamListener

Why StreamListener is deprecated

我正在为 KafkaStreams 使用 Spring Cloud Stream 3.1.2。编程模型是:

后一个使用注解作为Spring提供的所有其他注解使用。但是,有人提到

Starting with 3.1.0 version of the binder, we recommend using the functional programming model described above for Kafka Streams binder based applications. The support for StreamListener is deprecated starting with 3.1.0 of Spring Cloud Stream.

因为我认为旧模型更具可读性(至少对我而言)。谁能解释为什么决定弃用函数式编程并将其删除?

来自 Spring 博客 post (https://spring.io/blog/2019/10/17/spring-cloud-stream-functional-and-reactive) it says 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. This is in favor to use event stream abstractions (such as Flux and Mono) that are provided by Project Reactor (https://projectreactor.io/)。命令式函数在每个单独的事件上触发,而反应式函数只触发一次。