What are KafkaListener Annotation Properties?
Learning2Code
Last updated on
Your thoughts?
Share your thoughts
@KafkaListener annotation allows you to configure underlying consumer like so...
@Component public class Listener { @KafkaListener(properties = {"bootstrap.servers=localhost:9092"}, id = "foo", topics = "myTopic") public void listen(String data) { System.out.println(data); } }
Notice how you can set things like topics and consumerGroupId as well as underlying consumer properties via the properties = {}...
properties that allow you to configure the consumer that you are really setting up under the hood when you use such annotations :)
I think most of these are optional...I have only had issues when I don't include id and topics...makes sense.