Why StreamListener is deprecated
Asked Answered
M

1

8

I am using Spring Cloud Stream 3.1.2 for KafkaStreams. The programming models are:

  • Functional Programming
  • Imperative Programming

The latter one uses annotations as all the other annotations that the Spring is provided to be used. But, it is mentioned that

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.

As I think the older model is more readable (at least for me). Can anyone explain why it is decided to be deprecated in favor of functional programming and will it be removed?

Mencher answered 2/4, 2021 at 20:38 Comment(0)
Y
7

From the Spring blog 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/). Imperative functions are triggered on each individual event, while reactive functions are triggered once.

Yonit answered 3/4, 2021 at 9:33 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.