From the course: Apache Kafka Essential Training: Getting Started (2021)

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Consuming messages in Java

Consuming messages in Java

From the course: Apache Kafka Essential Training: Getting Started (2021)

Start my 1-month free trial

Consuming messages in Java

- [Instructor] Let's execute the Kafka consumer, we built in the previous video and review the results. Let's run the code now. We immediately see that all previously published messages are returned to the console. For each message, we see the topic name, the partition this message belongs to, and the offset for the message. We see the timestamp of the message as create time. The publish key and the value are also shown. We also see that the program continues to run, and wait for more data. Let's stop and restart the program again. Even though we specified it to publish from the earliest offset, it now does not print any of the old data. This is because based on the previous run, Kafka has incremented the committed offset for this consumer group, and will only provide new messages going forward. To force it to publish from the beginning, we need to request from a specific hard-coded offset of zero. Please check out…

Contents