I am trying to publish an Avro message to a Kafka topic using JMeter.
I get the below error message:
Caused by: javax.script.ScriptException: org.apache.kafka.common.errors.SerializationException: Error retrieving Avro schema"string"
I used the following code using JSR223 sampler.
KAFKA_BROKERS, KAFKA_TOPIC & MESSAGE are passed in User Defined variables.
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
String brokers = vars.get("KAFKA_BROKERS");
String topic = vars.get("KAFKA_TOPIC");
String user = String.valueOf(ctx.getThreadNum() + 1);
Object msg = vars.get("MESSAGE");
Properties kafkaProps = new Properties();
kafkaProps.put("bootstrap.servers", brokers);
kafkaProps.put("schema.registry.url","https://\<\>");
kafkaProps.put("auto.register.schemas","false");
kafkaProps.put("basic.auth.credentials.source","USER_INFO");
kafkaProps.put("basic.auth.user.info","\<\>");
kafkaProps.put("security.protocol","SASL_SSL");
kafkaProps.put("sasl.mechanism","PLAIN");
kafkaProps.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
kafkaProps.put("value.serializer","io.confluent.kafka.serializers.KafkaAvroSerializer");
kafkaProps.put("sasl.jaas.config","org.apache.kafka.common.security.plain.PlainLoginModule required username='\<\>' password='\<\>';");
Producer\<String, Object\> producer = new KafkaProducer\<\>(kafkaProps);
try
{
producer.send(new ProducerRecord\<String, Object\>(topic, user, msg)).get();
}
finally
{
producer.close();
}
Getting the below error message:
Caused by: javax.script.ScriptException: org.apache.kafka.common.errors.SerializationException: Error retrieving Avro schema"string"