I am finding a strange behaviour when using Kafka on Confluent Cloud. I have created a topic with the default partitioning value: 6.
My system consists of a Java Producer application that sends a message to that topic and a Kafka Streams application that reads from it and performs an operation per message.
----------------------- -------- -----------
| Kafka Java Producer | ----> | topic | ----> | KStream |
----------------------- -------- -----------
At the moment I am starting only one instance of the Kafka Streams application, so the consumer group has one member.
This is what I've observed:
- The producer sends a message and it is recorded in the event topic with offset 0:
- The message reaches the KStream, being processed correctly as I can see in the KStream log trace:
KStream
events.foreach { key, value ->
logger.info("--------> Processing TimeMetric {}", value)
//Store in DB
Log
[-StreamThread-1] uration$$EnhancerBySpringCGLIB$$e72e3f00 : --------> Processing Event {"...
- In the Confluent Cloud consumer lag I can see all consumer groups and their state. There's one for the KStream called
events-processor-19549050-d8b0-4b39...
. As stated before, this group has only one member (the only instance of the KStream). However, if shows that this group is behind one message in the partition 2. Besides, note that current offset seems to be 1 and end offset 2):
- If I send another message in the producer, it is recorded again in the topic but this time with offset 2 instead of 1:
- The message reaches the KStream and is processed normally again:
[-StreamThread-1] uration$$EnhancerBySpringCGLIB$$e72e3f00 : --------> Processing Event {
- And going back to the consumer lag of the consumer group it is still one message behind, still with some strange offsets (current 3, end 4):
Although the processing seems to be fine, the state showed above doesn't make much sense. Can you explain the reasons why:
- the message offsets are incremented +2 instead of +1?
- the consumer group seems to be 1 message behind even though it processed the messages correctly?