Example #1
0
 public void send(SimplifiedLog message, String topicName) {
   if (producer == null) {
     producer =
         KafkaUtils.createProducer("localhost:" + kafkaPort, KafkaProducerType.ASYNC, false);
   }
   producer.send(new KeyedMessage<>(topicName, message.getHostName(), message));
   LOGGER.debug("Sent message: {}", message);
 }
Example #2
0
 public void produce(SimplifiedLog message, String topicName) {
   if (producer == null)
     producer =
         KafkaUtils.createProducer(
             KafkaUtils.createZkClient(zkServer.getConnectString()), ASYNC, false);
   producer.send(new KeyedMessage<>(topicName, message.getHostName(), message));
   LOGGER.debug("Sent message: {}", message);
 }