Gatling Expression Language doesn't work in functions

Hi, I have a feeder counter like: val counterFeeder: Iterator[Map[String, Int]] = Iterator.continually(Map(“counter” → count.getAndIncrement())).
I have the following scenarioBuilder

  val scenarioBuilder: ScenarioBuilder = scenario("Kafkaimport")
        .send(session => {
          val c: String = "import_#{counter}"
          "6:" + String.format("%06d", #{counter})
        }, sessionA => {
          val data: Record = data.template
          data.setCounter(String.format("%06d",  "#{counter}"))

In the section kafka(“import_#{counter}”) I get the value of my feeder counter correctly. But in the session Block e.g. here val c: String = “import_#{counter}” or String.format(“%06d”, #{counter} there is not the feeder value. If I print it out e.g. herer println(c) ==> console outpur: “mport_#{counter}. I have also tried with s”${counter}" but it does not help. Does anyone has an idea, why it does not work and how i get the value from the feeder in mein session block ?

data.setCounter(String.format(“%06d”, “#{counter}”))

The Gatling Expression Language documentation explicitly states that it doesn’t work in functions in a big yellow warning box.

1 Like
val c: String = "import_#{counter}"

that also does not work

Indeed, as expected. You have to use the Session API.

1 Like