Bird
0
0

If you run kafka-console-consumer.sh --topic my-topic --from-beginning --bootstrap-server localhost:9092 and the topic has 5 messages, what will happen?

medium📝 Predict Output Q5 of 15
Kafka - Basics and Event Streaming
If you run kafka-console-consumer.sh --topic my-topic --from-beginning --bootstrap-server localhost:9092 and the topic has 5 messages, what will happen?
AThe command will fail with an error
BOnly new messages after the command starts will be printed
CNo messages will be printed
DAll 5 messages will be printed from the start
Step-by-Step Solution
Solution:
  1. Step 1: Understand the --from-beginning flag

    This flag tells the consumer to read all messages from the start of the topic.
  2. Step 2: Apply to the topic with 5 messages

    Since the topic has 5 messages, all will be printed on running the command.
  3. Final Answer:

    All 5 messages will be printed from the start -> Option D
  4. Quick Check:

    --from-beginning prints all existing messages [OK]
Quick Trick: Use --from-beginning to read all past messages [OK]
Common Mistakes:
  • Assuming only new messages print
  • Thinking command fails without extra flags
  • Expecting no output if topic exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes