title: Spring Kafka configuration for high consumer processing time
body: <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.kafka&lt;/groupId&gt;
      &lt;artifactId&gt;spring-kafka&lt;/artifactId&gt;
      &lt;version&gt;2.8.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>I have a kafka consumer that takes anywhere from 30-120 seconds to process a record.</p>
  <p>Configuration</p>
  <pre class="lang-java prettyprint-override"><code>@Bean
      public ConcurrentKafkaListenerContainerFactory&lt;String, GGP&gt; kafkaListenerContainerFactory() {
  
          ConcurrentKafkaListenerContainerFactory&lt;String, GGP&gt; factory =
                  new ConcurrentKafkaListenerContainerFactory&lt;&gt;();
          factory.setConsumerFactory(consumerFactory());
          factory.setConcurrency(10);
          return factory;
      }
  </code></pre>
  <p>What are some considerations to make when setting the following config vals for consumers that can take multiple minutes to complete the consumption of a record.</p>
  <pre><code>heartbeat.interval.ms # default 3 seconds
  session.timeout.ms # default 45 seconds
  request.timeout.ms # default 30 seconds
  max.poll.interval.ms # default 5 mins
  </code></pre>
  <p>As I currently understand <code>max.poll.interval.ms</code> should be longer than the processing time of a single record but by how much (is there a good rule of thumb)? I understand that the larger this value the longer it will take to recover from an actual failure. However if this value is too low then it will fail prematurely. Do any of the other configurations need to change because of such a long processing time?</p>