Convert Vector to Feeder

I have a Vector[String] of links that I do a foreach over in a Simulation. The link should only be processed by one user so then I have tried to create a Feeder but with no success.

So what I’m trying to do is to replace “First exec” with “Second exec”

//First exec
.exec(foreach("${taskLinks}", "taskLink")
  {
     exec(session => {
        println("In foreach")
        session
      })
  }      
)
//Second exec
.exec(session => {
      val taskMap = session("taskLinks").as[Vector[String]].map(a => Map("taskLink2" -> a))
      val feeder = taskMap.queue
      feed(feeder)
      .exec(session2 => {
        //Here I would like to access "${taskLink2}"
        println("In feeder")
        session2
      })
      println("In exec session")
      session         

})

This is the output. “In feeder” is never printed

In foreach
In foreach
In exec session

How can I convert this Vector into a Feeder?

You are confusing build-time vs. run-time behavior. You can’t put the feed().exec() in the middle of your exec(session=>{}) block.

Any ideas how I can get the same behavior as a JSON Feeder?
I can’t use the standard feeder because the endpoint is not public available.

This is how I get the taskLinks in the previous mail

val getTaskLinks = http("get task links")
    .get("""/tasks""")
    .header("Authorization", "bearer ${userToken}")
    .check([status.is](http://status.is)(200),
            jsonPath("$..Links[?(@.Relation == 'task-detail')].Href")
              .findAll
              .saveAs("taskLinks"))

The link in the list should only be processed by one user in the simulation. So no more than one user should see the same link. That’s why I thought I need a Feeder instead of a foreach

Answering the first question: you have a Vector[String], and want a Seq[Map[String, String]]:

vector.map(link => Map(“link” → link))

Regarding the fact that you want to set an authentication header to a JSON feeder, that’s not possible at the moment.
I’ve opened an issue: https://github.com/gatling/gatling/issues/2692
Feel free to contribute :slight_smile: