Plugin to support Kafka in Gatling (3.9.x)+
Gatling Version | Kafka Plugin Version | Notable Changes |
---|---|---|
3.9.x - 3.11.x | Releases up to 0.15.1 | May require additional akka dependency in your dependencies - e.g. com.typesafe.akka:akka-actor_2.13:2.6.20 |
3.13.x | Releases after 0.15.1 | Akka dependency no longer required |
This plugin is currently available for Scala 2.13 / Java 17 / Kotlin. To use it, you should include it as a dependency in your gatling project with your tests. To include:
libraryDependencies += "org.galaxio" %% "gatling-kafka-plugin" % <version>% Test
Add this to your dependencies block in build.gradle:
gatling "org.galaxio:gatling-kafka-plugin_2.13:<version>"
Add this to your dependencies block in build.gradle:
gatling("org.galaxio: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
When contributing to this project - check your build with:
sbt clean scalafmtCheckAll scalafmtSbtCheck compile coverage "Gatling / testOnly org.galaxio.gatling.kafka.examples.KafkaGatlingTest" test coverageOff
Reference to ci.yml