-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathFeederByteArraySimulation.scala
29 lines (23 loc) · 1.03 KB
/
FeederByteArraySimulation.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package io.gatling.simulation
import java.util
import io.gatling.core.Predef._
import io.gatling.core.Predef.Simulation
import io.gatling.kafka.{KafkaProducerBuilder, KafkaProducerProtocol}
import org.apache.kafka.clients.producer.ProducerConfig
import org.apache.kafka.common.serialization.ByteArraySerializer
class FeederByteArraySimulation extends Simulation {
val kafkaTopic = "test_topic"
val kafkaBrokers = "localhost:9092"
val props = new util.HashMap[String, Object]()
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaBrokers)
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
classOf[ByteArraySerializer])
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
classOf[ByteArraySerializer])
val kafkaProducerProtocol =
new KafkaProducerProtocol[Array[Byte], Array[Byte]](props, kafkaTopic)
val scn = scenario("Kafka Producer Call")
.feed(csv("test_data1.csv").circular)
.exec(KafkaProducerBuilder[Array[Byte], Array[Byte]]())
setUp(scn.inject(atOnceUsers(5))).protocols(kafkaProducerProtocol)
}