Gatling 3.5.0 Batching feeder throws feeder empty

Hi,

val contactCreateScn = scenario("Contact Create Req")
  .exec(Auth.setHeaderValues)
  .repeat(10) {
    exec(
      RequestFormatter.postContactCreate
    ).exec(session => {
      println(">>>>>>>>>............"+session("contactId").as[String])
      writer.write(session("contactId").as[String])
      writer.write("\n")
      session
    })
  }

I have the above scenario to write values to a csv

I am using the below scenario ( the csv written above is used as feeder here )

val contactGetScn = scenario("Contact Get Req")
  .exec(Auth.setHeaderValues)
  .feed(csv("primarycontact.csv").batch(2))
  .repeat(5) {
    exec(
      RequestFormatter.getContact
    )
  }

My setup:

setUp(
  contactCreateScn.inject(atOnceUsers(1))
    .andThen(contactGetScn.inject(atOnceUsers(2)))
  ).protocols(http
    .baseUrl("https://bam.nr-data.net"))

But then I experience the below error

java.lang.IllegalStateException: Feeder is now empty, stopping engine

where as the contact create req is successful and could see values in csv too

  1. the column headers must be present when the simulation is created
  2. the file must be fully populated when the first chunk is read
  1. Yes there’s header in csv

  2. The data is written in parent scenario itself. Doesn’t it mean the data is already populated? As I don’t write any data to csv in the child scenario.

How many records do you write in the feeder file in the parent scenario?
How many records are you trying to pull from the feeder in the child one?

10 records.

trying to fetch batches of 2.

You have a flushing issue.
You’re most likely using a PrintWriter which is backed by a BufferedOutputStream.
You’re writing very little data, not enough to fill the buffer and trigger the flush, so you have to flush manually.

You need to flush at least twice:

  • after writing the headers line
  • once you’re done writing (you can do that by closing the writer as a first step in the child scenario)