title: Kafka producer TimeoutException: Expiring 1 record(s)
body: <p>I am using Kafka with <strong>Spring-boot:</strong> </p>
  
  <p><strong>Kafka Producer class</strong>: </p>
  
  <pre class="lang-java prettyprint-override"><code>@Service
  public class MyKafkaProducer {
  
      @Autowired
      private KafkaTemplate&lt;String, String&gt; kafkaTemplate;
  
      private static Logger LOGGER = LoggerFactory.getLogger(NotificationDispatcherSender.class);
  
      // Send Message
      public void sendMessage(String topicName, String message) throws Exception {
          LOGGER.debug("========topic Name===== " + topicName + "=========message=======" + message);
          ListenableFuture&lt;SendResult&lt;String, String&gt;&gt; result = kafkaTemplate.send(topicName, message);
          result.addCallback(new ListenableFutureCallback&lt;SendResult&lt;String, String&gt;&gt;() {
              @Override
              public void onSuccess(SendResult&lt;String, String&gt; result) {
                  LOGGER.debug("sent message='{}' with offset={}", message, result.getRecordMetadata().offset());
              }
  
              @Override
              public void onFailure(Throwable ex) {
                  LOGGER.error(Constants.PRODUCER_MESSAGE_EXCEPTION.getValue() + " : " + ex.getMessage());
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>Kafka-configuration:</strong> </p>
  
  <pre><code>spring.kafka.producer.retries=0
  spring.kafka.producer.batch-size=100000
  spring.kafka.producer.request.timeout.ms=30000
  spring.kafka.producer.linger.ms=10
  spring.kafka.producer.acks=0
  spring.kafka.producer.buffer-memory=33554432
  spring.kafka.producer.max.block.ms=5000
  spring.kafka.bootstrap-servers=192.168.1.161:9092,192.168.1.162:9093
  </code></pre>
  
  <p>Let's say I have sent 10 times 1000 messages in topic <code>my-test-topic</code>.</p>
  
  <p>8 out of 10 times I am successfully getting all messages in my consumer but sometimes I am getting this below <strong>error</strong>: </p>
  
  <p><code>2017-10-05 07:24:11, [ERROR] [my-service - LoggingProducerListener - onError:76] Exception thrown when sending a message with key='null' and payload='{"deviceType":"X","deviceKeys":[{"apiKey":"X-X-o"}],"devices...' to topic my-test-topic</code></p>
  
  <p>and <code>org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for my-test-topic-4 due to 30024 ms has passed since batch creation plus linger time</code></p>