Using data from a custom feeder

Hi, I’m using gatling 2 M3. Everything seems to be working fine except when I try to use my custom feeder.

object File2Json extends Feeder[String] {

val feedIter = readCsvInStream.iterator //I can’t use feeder(‘path’).csv because i’m doing a lot more work to compose data

override def next(): Map[String, String] = {
val next = feedIter.next()
val json: String = next.toJson
Map(“payload” → json)
}

override def hasNext: Boolean = feedIter.hasNext
}

val scen = scenario(“Load on server”)
.feed(File2Json)
.exec(
http(“post first round of requests”)
.post("/restEndPoint")
.headers(httpHeaders)
// .body() //what exactly to do here?
.check(status.is(200))
)

setUp(scen.inject(nothingFor(2 seconds), ramp(200 users) over (120 seconds))).protocols(httpConf)

How do I pull the “payload” data (which is simply a String) into each execution cycle as an http request body?

First, just being curious: what kind of work do you do to compose data?

Then, the answer you’re looking for is .body(StringBody("${payload}"))

https://github.com/excilys/gatling/wiki/Gatling%202#wiki-bodies

Dang! I was missing {} around ‘payload’.

For data composition i’m reading a huge csv file and zipping some ids and some fields in my json presentation. If I use default csv feeder, gatling crashes by going out of memory too.

Thanks for the quickie.

Nabeel