1
votes

When I have a kafka console producer message produce some messages and then start a consumer, I am not getting the messages.

However i am receiving message produced by the producer after a consumer has been started.Should Kafka consumers be started before producers?

--from- beginning seems to give all messages including ones that are consumed.

Please help me with this on both console level and java client example for starting producer first and consuming by starting a consumer.

1
We need to see your code in order to help you..Felix D.

1 Answers

1
votes

Kafka stores messages for a configurable amount of time. Default is a week. Consumers do not need to be "available" to receive messages, but they do need to know where they should start reading from

The console consumer has the default option of looking at the latest offset for all partitions. So if you're not actively producing data you see nothing as a consumer. You can specify a group flag for the console consumer or a Java client, and that's what tracks what offsets are read within the Kafka protocol and where a read request will resume from if you stopped that consumer in a group

Otherwise, I think you can only give an offset along with a single partition to consume from