rm12345
rm12345

Reputation: 1229

Apache Kafka: Replay messages in a topic

I'm considering using Apache Kafka as an event store for storing events within a microservice.

One thing that I read through various blogs is that Kafka can be considered to be a single source of truth, where Kafka log will store all the events for a given topic.

I was wondering if Kafka has the ability to replay messages since the beginning of time (in case there is a hard drive/network crash that occurs for example)?

(note that i see that there are some logs stored in the /tmp folder under a topic directory). Does anyone know of any command (if any) that can be invoked to replay the messages in the topic?

Upvotes: 21

Views: 39147

Answers (2)

Vishal Akkalkote
Vishal Akkalkote

Reputation: 1351

Yes, You can replay message. As Consumer have a control over resetting the offset. You can start reading messages from the beginning or if you know any existing offset value you can read it from there as well. Once the message is committed it will be in there in topic until its retention period is over. Default retention period is 7 days, however you can change it any time.

Upvotes: 5

Gary Russell
Gary Russell

Reputation: 174769

Yes, you can seek to a specific offset, but

beginning of time

depends on the topic or broker configuration. IIRC, the default retention is 7 days.

Refer to the the Kafka documentation.

Upvotes: 13

Related Questions