In Kafka, each topic has multiple partitions. Each partition calculates the total number of messages, which is known as the maximum offset (MaxOffset). A Kafka consumer consumes messages in a partition in sequence and records the number of consumed messages, which is known as the consumer offset (ConsumerOffset).
The number of unconsumed messages is calculated by subtracting ConsumerOffset from MaxOffset. This number indicates the number of accumulated messages.