Bird
0
0

Which annotation is used to mark a method as a Kafka message listener in Spring Boot?

easy📝 Conceptual Q2 of 15
Spring Boot - Messaging
Which annotation is used to mark a method as a Kafka message listener in Spring Boot?
A@KafkaConsumer
B@KafkaProducer
C@KafkaListener
D@KafkaHandler
Step-by-Step Solution
Solution:
  1. Step 1: Identify the listener annotation

    The annotation to listen to Kafka topics is @KafkaListener.
  2. Step 2: Exclude other incorrect annotations

    @KafkaProducer and @KafkaConsumer are not valid Spring annotations; @KafkaHandler is for message handling but not listener registration.
  3. Final Answer:

    @KafkaListener -> Option C
  4. Quick Check:

    Listener annotation = @KafkaListener [OK]
Quick Trick: Use @KafkaListener to receive Kafka messages [OK]
Common Mistakes:
  • Using @KafkaConsumer instead of @KafkaListener
  • Confusing @KafkaHandler with listener annotation
  • Assuming @KafkaProducer listens to messages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes