Plugin to support Kafka in Gatling (3.9.x)
Plugin is currently available for Scala 2.13, Java 17, Kotlin.
You may include plugin as dependency in project with your tests. Write
libraryDependencies += "ru.tinkoff" %% "gatling-kafka-plugin" % <version> % Test
Write this to your dependencies block in build.gradle:
gatling "ru.tinkoff:gatling-kafka-plugin_2.13:<version>"
Write this to your dependencies block in build.gradle:
gatling("ru.tinkoff:gatling-kafka-plugin_2.13:<version>")
Examples here
Examples here
Examples here
Avro schema is downloaded using the plugin sbt-schema-registry-plugin
and for that you need to configure schemas and url in build.sbt
and run the command:
sbt schemaRegistryDownload
To create java classes you should add use capabilities, that provide plugin sbt-avro.
This plugin is included in project and will do all needed for creating java classes in compile stage.
To run you should create scala object in root project directory and type sbt run
.
Example here
To use avro messages as payload in key or value, you must:
- define implicit for schema registry url:
implicit val schemaRegUrl: String = "http://localhost:9094"
- or define serde for your class:
val ser =
new KafkaAvroSerializer(
new CachedSchemaRegistryClient("schRegUrl".split(',').toList.asJava, 16),
)
val de =
new KafkaAvroDeserializer(
new CachedSchemaRegistryClient("schRegUrl".split(',').toList.asJava, 16),
)
implicit val serdeClass: Serde[MyAvroClass] = new Serde[MyAvroClass] {
override def serializer(): Serializer[MyAvroClass] = ser.asInstanceOf[Serializer[MyAvroClass]]
override def deserializer(): Deserializer[MyAvroClass] = de.asInstanceOf[Deserializer[MyAvroClass]]
}
To use avro messages as payload in key or value, you must define serde for your class:
public static Serializer<MyAvroClass> ser = (Serializer) new KafkaAvroSerializer(new CachedSchemaRegistryClient(Arrays.asList("schRegUrl".split(",")), 16));
public static Deserializer<MyAvroClass> de = (Deserializer) new KafkaAvroDeserializer(new CachedSchemaRegistryClient(Arrays.asList("schRegUrl".split(",")), 16));
To use avro messages as payload in key or value, you must define serde for your class:
val ser = KafkaAvroSerializer(CachedSchemaRegistryClient("schRegUrl".split(','), 16),) as Serializer<MyAvroClass>
val de = KafkaAvroDeserializer(CachedSchemaRegistryClient("schRegUrl".split(','), 16),) as Deserializer<MyAvroClass>
Example scala
Example java
Example kotlin