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
I have created a new Java Virtual user.
This is the simple code that i have used producing messaging:
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<String, String> producer = new KafkaProducer <String,String>(props);
ProducerRecord<String, String> record = new ProducerRecord<String,String>(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
}
Add all required jars in classpath under runtime settings.
By this i am able to connect to Kafka cluster.
As i have used java to send request will it impact on end results?