0

Step 1: create Topic with only one partition:

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

Step 2: Produce some message to topic test.

Step 3: Start a consume on topic test. It can get all messages which is pushed in Step 2.

It works fine with topic with 1 partition.

But when I try to use topic with 2 partitions, consumer only get messages which are generated after the consumer is up.

Reproduce:

Step 1: create Topic with only one partition:

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test2

Step 2: Produce some message to topic test2.

Step 3: Start a consumer on topic test2. It can't get messages in Step 2.

Step 4: keep consumer on, produce some message to topic test2, then now the consumer can get messages.

Does it work fine? Or I miss something?

IRON
  • 43
  • 1
  • 6

1 Answers1

1

auto.offset.reset option's default value is 'latest'

If you want to read the message that was sent before the consumer set auto.offset.reset:earliest

bistros
  • 1,139
  • 1
  • 9
  • 23