Custom Feeder based on data being dynamically populated

Hi,

I have two scenarios being run at the same time. I need the data from one scenario to be fed into another scenario. The logic is that the one scenario is generating new random data and the service under test is returning unique identifiers for that data. The second scenario is to then modify that data. The information needed to run the scenario is the unique identifiers that were returned on the call in the first scenario. The feeder for the second scenario should randomly pick an identifier from the list of identifiers. I have the second scenario being delayed by a period of time so that there is time for enough unique identifiers to be added. Unfortunately I don’t know how to do this with Gatling .feed() call. Anyone able to offer an example that I could work off?

Thanks

I’m curious: do you need two scenarios? Or two steps in a single scenario? that is, can you have a single scenario that first creates the random data, and then waits a short time, and then modifies it?

Really, what is the business process you are trying to model?

The model is whereby a user submits a piece of data for another user. That scenario has a high throughput. Occasionally the other user will mark something as being read. This happens at a lower throughput and at some random time after the data shows up. So with the two scenario model I can push through data at the required TPS and then another scenario can mark things as read at that required TPS. I have been doing this in the past by first pulling out a random list of identifiers and putting them into a csv file and using that as a feeder. That setup isn’t the most convenient so I was looking for a way for the result of an http request in one scenario being the data for another scenario.

I’d use something like a concurrent queue.

Do you have an example of how to set this up? I am guessing I would need to build my own custom feeder class and have the queue within there being fed from the one scenario. I am just not as familiar with how to do this with Gatling / Scala.

import java.util.concurrent.ConcurrentLinkedDeque
val queue = new ConcurrentLinkedDeque[Map[String, Any]]

def offer(record : Map[String, Any]) = exec { session =>
queue.offer(record)
session
}

import io.gatling.core.structure.ChainBuilder
def withPolledRecord(chain: ChainBuilder) = exec { session =>
queue.poll() match {
case null => session.set(“emptyQueueFlag”, true)
case record => session.setAll(record).remove(“emptyQueueFlag”)
}
}.asLongAs(“emptyQueueFlag.exists()”)(chain)

Thanks, this answered my need as well with minor modifications. If someone is interested, the code is published here https://github.com/meetpraveen/gatling-custom-dsls/blob/master/README.md#producer-consumer-contract-prallel-scenarios-- .