I have a code similar to the one below:
KafkaConsumer<Long, String> kafkaConsumer = new KafkaConsumer<>(properties);
partitions = Collections.singletonList(new TopicPartition(topic, partition));
kafkaConsumer.assign(partitions);
kafkaConsumer.seekToBeginning(List.of(partition));
ConsumerRecords<Long, String> records = kafkaConsumer.poll(Duration.ofMillis(pollDuration));
While running the code, I am not able to get all the messages in this particular topic. For example, if I have 24 records in this partition, I am able to get only 20 records.
This issue does not happen always. When we make Kafka (wurstmeister/kafka:1.1.0) up using docker in the same machine in which my application runs, I am able to get all records from that particular partition.
But when I make the same docker-compose up in another machine and connect to it, this issue happens.