Dynamic Data consumption in ActionBuilder


I’m relatively new to Gatling and kind of lost here.

In the code below:

  1. I’m creating an action (ActionBuilder)
  2. Creating a chain of actions with only the action in the first step (ChainBuilder)
  3. Create a scenario to feed data, and execute the action.
  4. Setup for 3 users for a max duration.
    What I’m stuck with is, when I create a scenario (it is created or executed the 3 times because my number of users are 3), I want to create a dynamic client for each user (want to keep mapping one user for one client) and use it while performing my action.

My question is to find out if there was a way to dynamically pass data to an action while the scenario is being built or maybe after the scenario is built but definitely before the execution of that action. I’ve tried to mention in code what I’m trying to do (DYNAMIC_CLIENT). Thanks in advance.

// Build create action.
val createNodes = new ActionBuilder {
  override def build(ctx: ScenarioContext, next: Action): Action = {
    val createNode = { node: String => DYNAMIC_CLIENT.create(node); }

// Create ZNodes chain.
val createNodesChain = ChainBuilder(List(createNodes))
val createScenario = scenario("Create node.")
  .exec { session => {

    // CREATE_DYNAMIC_CLIENT_HERE and use it up there.

setUp(createScenario.inject(atOnceUsers(3))).maxDuration(config.getDouble("runDuration") minutes)