title: Performance Testing Kafka using loadrunner
body: <p>I have been searching on google for a while whether is their any plugin in loadrunner to test Kafka cluster but found nothing. I realized lately that we can a send message through a java program with help of packages like apache.kafka.clients  </p>
  
  <p>I have created a new Java Virtual user. </p>
  
  <p>This is the simple code that i have used producing messaging:</p>
  
  <pre><code>import lrapi.lr;
  import java.util.*;
  import org.apache.kafka.clients.producer.*;
  
  public class Actions
  {
  
      public int init() throws Throwable {
          return 0;
      }//end of init
  
  
      public int action() throws Throwable {
          String topicName = "loadrunnertest";
        String key = "Key1";
        String value = "hello Vishal";
  
  
        Properties props = new Properties();
        props.put("bootstrap.servers", "localhost:9092");
        props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");         
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
  
        Producer&lt;String, String&gt; producer = new KafkaProducer &lt;String,String&gt;(props);
  
        ProducerRecord&lt;String, String&gt; record = new ProducerRecord&lt;String,String&gt;(topicName,key,value);
        producer.send(record);           
        producer.close();
  
        System.out.println("SimpleProducer Completed.");
        return 0;
      }//end of action
  
  
      public int end() throws Throwable {
          return 0;
      }//end of end
  }
  </code></pre>
  
  <p>Add all required jars in classpath under runtime settings.<br>
  By this i am able to connect to Kafka cluster.<br>
  As i have used java to send request will it impact on end results?</p>