# Gatling 3.5.0 Batching feeder throws feeder empty

**URL:** <https://community.gatling.io/t/gatling-3-5-0-batching-feeder-throws-feeder-empty/5965>\
**Category:** Gatling (Open-Source)\
**Created:** [January 22, 2021, 8:30am UTC](https://community.gatling.io/t/gatling-3-5-0-batching-feeder-throws-feeder-empty/5965 "2021-01-22T08:30:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sharanya\_Krishnamoor](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sharanya\_Krishnamoor](https://community.gatling.io/u/Sharanya_Krishnamoor)\
**Post date:** [January 22, 2021, 8:30am UTC](https://community.gatling.io/t/gatling-3-5-0-batching-feeder-throws-feeder-empty/5965/1 "2021-01-22T08:30:49Z")

</div>

Hi,

```scala
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 )

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

```

My setup:

```scala
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

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

```

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

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [January 22, 2021, 9:18am UTC](https://community.gatling.io/t/gatling-3-5-0-batching-feeder-throws-feeder-empty/5965/2 "2021-01-22T09:18:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sharanya\_Krishnamoor](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sharanya\_Krishnamoor](https://community.gatling.io/u/Sharanya_Krishnamoor)\
**Post date:** [January 22, 2021, 4:02pm UTC](https://community.gatling.io/t/gatling-3-5-0-batching-feeder-throws-feeder-empty/5965/3 "2021-01-22T16:02:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [January 22, 2021, 4:04pm UTC](https://community.gatling.io/t/gatling-3-5-0-batching-feeder-throws-feeder-empty/5965/4 "2021-01-22T16:04:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Sharanya\_Krishnamoor](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sharanya\_Krishnamoor](https://community.gatling.io/u/Sharanya_Krishnamoor)\
**Post date:** [January 22, 2021, 4:09pm UTC](https://community.gatling.io/t/gatling-3-5-0-batching-feeder-throws-feeder-empty/5965/5 "2021-01-22T16:09:22Z")

</div>

10 records.

trying to fetch batches of 2.

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [January 22, 2021, 5:03pm UTC](https://community.gatling.io/t/gatling-3-5-0-batching-feeder-throws-feeder-empty/5965/6 "2021-01-22T17:03:01Z")

</div>

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)
