I want to use Kafka with Spring Boot and with Avro schemas.
But I'm stucked on 'What is the difference between those 3 listeners?'.
There are 3 possibilities to create listeners: annotate a method with - @KafkaListener, @StreamListener or @ServiceActivator. Seems like all of them are listening for incoming events but I cannot see/find difference between those solutions.
So, I'll start with @KafkaListener. That one is simple as it is coming from "spring-kafka" project and can be used outside of Spring Cloud Stream.
The @ServiceActivator is coming from "spring-integraton" project and similarly to @KafkaListener can be used outside of Spring Cloud Stream.
Both can also be used inside of Spring Cloud Stream application - primarily for convenience.
The @StreamListener is the only one that is native to Spring Cloud Stream.
For simple cases you can make your pick. For more complex cases see the extra capabilities of a particular annotation. For example, you can define conditions when using @StreamListener.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With