When viewing the JMX Metric records-lag for a given topic and partition the records-lag should be somewhat comparable to the lag reported in Red Panda/Kafka while producing.
If the production of messages is faster than the consumption of messages the records-lag should increase over time.
If producing to kafka is done via a REST Controller in the project, then the records-lag in JMX does not increase, but the consumer lag does increase when viewed in Red Panda/Kafka.
What's even stranger, is if you pre-load the topic with messages (say 10k) and start the app, then it records the records-lag correctly.
8. Execute Application
9. Confirm Lag for consumer is 0 in JMX and Red Panda/Kafka
10. `curl -X POST http://localhost:8082/produce/batch/10/100000`
11. Confirm Lag is increasing in Red Panda/Kafka for consumer
12. Confirm jmx kafka.consumer -> consumer-fetch-manager-metrics -> consumer-consumer-11 -> chat-room -> 0 -> Attributes -> records-lag is not increasing
### Environment Information
- Operating System: Windows 11
- JDK: Adoptium Temurin 21
### Example Application
https://github.com/retinaburn/micronaut-kafka-investigation
### Version
4.2.0
Expected Behavior
When viewing the JMX Metric
records-lag
for a given topic and partition the records-lag should be somewhat comparable to the lag reported in Red Panda/Kafka while producing.If the production of messages is faster than the consumption of messages the
records-lag
should increase over time.Actual Behaviour
If producing to kafka is done via consumption thread then its reported correctly, with the
records-lag
increasing over time as documented in https://github.com/micronaut-projects/micronaut-kafka/issues/634If producing to kafka is done via a REST Controller in the project, then the records-lag in JMX does not increase, but the consumer lag does increase when viewed in Red Panda/Kafka.
What's even stranger, is if you pre-load the topic with messages (say 10k) and start the app, then it records the records-lag correctly.
Steps To Reproduce
kafka
,micrometer-jmx
,micrometer-prometheus
, with name: consumer, java version: 21Define Consumer:
}
@KafkaClient(id="producer") public interface Producer { @Topic("${topic.chat}") void sendChat(@KafkaKey String key, String value); }
@Controller("/produce") public class BatchController {
}