public void createTopicWithData(String topicName, File datafile){
    createTopic(topicName);
    // set up kafka producer
    Properties properties = new Properties();
    properties.put("bootstrap.servers", kafkaServer);
    properties.put("acks", "1");
    properties.put("retries", "3");

    try(KafkaProducer<String, String> producer = new KafkaProducer<>(
        properties,
        new StringSerializer(),
        new StringSerializer()
    )){
      List<String> events = Files.readLines(datafile, Charset.forName("UTF-8"));
      for(String event : events){
        producer.send(new ProducerRecord<>(topicName, "key", event));
      }
    } catch (IOException e) {
      Throwables.propagate(e);
    }
  }
Creates a topic and inserts data from the specified datafile.
Each line in the datafile is sent to kafka as a single message.
@param topicName
@param datafile
itests/qtest-druid/src/main/java/org/apache/hive/kafka/SingleNodeKafkaCluster.java