Bird
0
0

Which of the following is the correct way to send a message to a Kafka topic using Spring Boot?

easy📝 Syntax Q12 of 15
Spring Boot - Messaging
Which of the following is the correct way to send a message to a Kafka topic using Spring Boot?
Anew KafkaProducer().send("topicName", "message")
B@KafkaListener(topic = "topicName")
CKafkaTemplate.listen("topicName", "message")
DkafkaTemplate.send("topicName", "message")
Step-by-Step Solution
Solution:
  1. Step 1: Identify the sending method in Spring Boot

    Spring Boot uses KafkaTemplate with the send() method to send messages.
  2. Step 2: Check syntax correctness

    kafkaTemplate.send("topicName", "message") is the correct syntax to send a message.
  3. Final Answer:

    kafkaTemplate.send("topicName", "message") -> Option D
  4. Quick Check:

    Sending uses KafkaTemplate.send() [OK]
Quick Trick: Send messages with kafkaTemplate.send() [OK]
Common Mistakes:
  • Using @KafkaListener to send messages
  • Calling listen() instead of send()
  • Instantiating KafkaProducer manually in Spring Boot

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes