title: Kafka consumer takes a long time to get the message
body: <p>I wrote function test for my system on Java</p>
  <p><strong>Test scenario</strong><br>
  In test I create two topics: &quot;topicFunc1&quot;, &quot;2_1&quot;.<br>
  The producer from the test sends a message to the topic &quot;topicFunc1&quot;, the consumer from my system receives a message, some actions are performed and the producer of the system sends a message to the topic &quot;2_1&quot;. The consumer in the test tries to get messages from the topic &quot;2_1&quot; and this happens only after 3-4 seconds. But when I send a message to the topic &quot;topicFunc1&quot; it is performed instantly.<br></p>
  <p>My problem is that the consumer from the test cannot quickly get the message from the topic.<br>
  For analysis, I used the test log, as well as the wireshark utility</p>
  <p><strong>Log from test:</strong></p>
  <pre><code>[2022.08.29 10:55:48.094] [DEBUG] [main] [httpApi.utils.kafka.KafkaProducerUtils.publishMessagesString() at line 47]        Send message &quot;{&quot;subsId&quot;:3}&quot; to kafka topic: topicFunc1
  [2022.08.29 10:55:48.156] [DEBUG] [main] [httpApi.utils.kafka.KafkaConsumerUtilsWithConstructor.getMessages() at line 43]       execute poll())
  [2022.08.29 10:55:48.156] [DEBUG] [System_Processor] [kafkaApi.KafkaStringConsumer.processRecord() at line 24]      Received message: value = {&quot;subsId&quot;:3}, topic = topicFunc1
  [2022.08.29 10:55:48.235] [DEBUG] [System_Processor] [kafkaApi.KafkaSimpleProducer.produce() at line 46]        sent record( message={&quot;result&quot;:&quot;1_1&quot;}) meta(partition=0, offset=0) to topic = 2_1
  [2022.08.29 10:55:48.235] [DEBUG] [System] [kafkaApi.EpmKafkaConsumer.commitOffsets() at line 182]      Consumer : epm.1, committing the offsets : {topicFunc1-0=OffsetAndMetadata{offset=1, leaderEpoch=null, metadata=''}}
  [2022.08.29 10:55:49.156] [DEBUG] [main] [httpApi.utils.kafka.KafkaConsumerUtilsWithConstructor.getMessages() at line 45]       look at list messages!)
  [2022.08.29 10:55:49.156] [DEBUG] [main] [httpApi.utils.kafka.KafkaConsumerUtilsWithConstructor.getMessages() at line 43]       execute poll())
  [2022.08.29 10:55:50.172] [DEBUG] [main] [httpApi.utils.kafka.KafkaConsumerUtilsWithConstructor.getMessages() at line 45]       look at list messages!)
  [2022.08.29 10:55:50.172] [DEBUG] [main] [httpApi.utils.kafka.KafkaConsumerUtilsWithConstructor.getMessages() at line 43]       execute poll())
  [2022.08.29 10:55:51.187] [DEBUG] [main] [httpApi.utils.kafka.KafkaConsumerUtilsWithConstructor.getMessages() at line 45]       look at list messages!)
  [2022.08.29 10:55:51.187] [DEBUG] [main] [httpApi.utils.kafka.KafkaConsumerUtilsWithConstructor.getMessages() at line 43]       execute poll())
  [2022.08.29 10:55:51.218] [DEBUG] [main] [httpApi.utils.kafka.KafkaConsumerUtilsWithConstructor.getMessages() at line 45]       look at list messages!)
  [2022.08.29 10:55:51.218] [DEBUG] [main] [httpApi.utils.kafka.KafkaConsumerUtilsWithConstructor.lambda$getMessages$0() at line 49]      record.value() = {&quot;result&quot;:&quot;1_1&quot;})
  
  </code></pre>
  <p>The message from my system was sent at 10:55:48.235.<br>
  The consumer received the message at 10:55:51.218</p>
  <p><strong>WireShark log</strong></p>
  <pre><code>№        Source           Destination   Protocol     length         info                          time utc
  2638    ipMyServer      ipKafkaServer   Kafka        238        Kafka Produce v7 Request        2022-08-29 10:55:48,233929
  2639    ipKafkaServer   ipMyServer      Kafka        109        Kafka Produce v7 Response       2022-08-29 10:55:48,238583
  2891    ipMyServer      ipKafkaServer   Kafka        101        Kafka OffsetFetch v5 Request    2022-08-29 10:55:51,197174
  2892    ipKafkaServer   ipMyServer      Kafka        101        Kafka OffsetFetch v5 Response   2022-08-29 10:55:51,201233
  2903    ipMyServer      ipKafkaServer   Kafka        109        Kafka Offsets v5 Request        2022-08-29 10:55:51,210409
  2904    ipKafkaServer   ipMyServer      Kafka        105        Kafka Offsets v5 Response       2022-08-29 10:55:51,213951
  2905    ipMyServer      ipKafkaServer   Kafka        147        Kafka Fetch v11 Request         2022-08-29 10:55:51,214318
  2907    ipKafkaServer   ipMyServer      Kafka        190        Kafka Fetch v11 Response        2022-08-29 10:55:51,218333
  </code></pre>
  <p>The Kafka producer send Request at 10:55:48,233929. <br>
  Kafka Fetch Request was sent at 10:55:51,214318. <br><br>
  If we look at the &quot;Log from the test&quot;, we will see that the first poll() was executed at 10:55:48.156, then at 10:55:49.156, 10:55:50.172, 10:55:51.187. But in &quot;Wireshark Log&quot; the request was sent only at 10:55:51.<br>
  <strong>Why is this happening? What could be the reason for the delay?</strong></p>