Kafka
Kafka
Low-level consumers
There are two types of consumers in Kafka. First, the low-level
consumer, where topics and partitions are specified as is the offset
from which to read, either fixed position, at the beginning or at the
end. This can, of course, be cumbersome to keep track of which offsets
are consumed so the same records aren’t read more than once. So
Kafka added another easier way of consuming with:
High-level consumer
The high-level consumer (more known as consumer groups) consists of
one or more consumers. Here a consumer group is created by adding
the property “group.id” to a consumer. Giving the same group id to
another consumer means it will join the same group.
Now we have been looking at the producer and the consumer, and we will check at how
the broker receives and stores records coming in the broker.
We have an example, where we have a broker with three topics, where each topic has 8
partitions.
The producer sends a record to partition 1 in topic 1 and since the partition is empty the
record ends up at offset 0.
Next record is added to partition 1 will and up at offset 1, and the next record at offset 2
and so on.
This is what is referred to as a commit log, each record is appended to the log and there
is no way to change the existing records in the log. This is also the same offset that the
consumer uses to specify where to start reading.
Resourses :
https://www.youtube.com/watch?v=X79IjgIUDzU
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013 (slideshare.net)