Bird
0
0

Which of the following is the correct way to configure a Kafka topic name in a @KafkaListener annotation?

easy📝 Syntax Q3 of 15
Spring Boot - Messaging
Which of the following is the correct way to configure a Kafka topic name in a @KafkaListener annotation?
A@KafkaListener(topic = "orders")
B@KafkaListener(topics = orders)
C@KafkaListener(topics = "orders")
D@KafkaListener(topic = orders)
Step-by-Step Solution
Solution:
  1. Step 1: Check correct attribute name

    The attribute to specify topics is 'topics' (plural), not 'topic'.
  2. Step 2: Confirm string usage

    Topic names must be strings, so they require quotes around the name.
  3. Final Answer:

    @KafkaListener(topics = "orders") -> Option C
  4. Quick Check:

    Correct topic attribute and string = @KafkaListener(topics = "orders") [OK]
Quick Trick: Use 'topics' with quotes for topic names in @KafkaListener [OK]
Common Mistakes:
  • Using 'topic' instead of 'topics'
  • Omitting quotes around topic name
  • Passing variable without quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes