code: public void pushMessages(List<Pair<K, V>> messages) {
      for (Pair<K, V> message: messages) {
        this.producer.send(new ProducerRecord<>(topic, message.getKey(), message.getValue()), (recordMetadata, e) -> {
          if (e != null) {
            log.error("Failed to send message to topic {} due to exception: ", topic, e);
          }
        });
      }
    }
docs: Push all keyed messages to the Kafka topic.
  @param messages List of keyed messages to push to Kakfa.