title: How to skip corrupt (non-serializable) messages in Spring Kafka Consumer?
body: <p>This question is for Spring Kafka, related to <a href="https://stackoverflow.com/questions/32904383/apache-kafka-with-high-level-consumer-skip-corrupted-messages">Apache Kafka with High Level Consumer: Skip corrupted messages</a></p>
  
  <p>Is there a way to configure Spring Kafka consumer to skip a record that cannot be read/processed (is corrupt)?</p>
  
  <p>I am seeing a situation where the consumer gets stuck on the same record if it cannot be deserialized. This is the error the consumer throws.</p>
  
  <pre><code>Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of java.time.LocalDate: no long/Long-argument constructor/factory method to deserialize from Number value 
  </code></pre>
  
  <p>The consumer polls the topic and just keeps printing the same error in a loop till program is killed.</p>
  
  <p>In a @KafkaListener that has the following Consumer factory configurations,</p>
  
  <pre><code>Map&lt;String, Object&gt; props = new HashMap&lt;&gt;();
  props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
  props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
  props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
  </code></pre>