Execute scenarios sequentially with different injection profiles

Hello. I need the advice on how to improve my scenario, I found the way of how to implement it though not sure that it is the best way to implement things.

I need to run N number of users within scenario 1 and when they finished, I want to trigger scenario 2 for only one user. Basically, for my system, it means that users publish N requests to the system and then we trigger the job which process all those requests. Afterwards, the system will generate N new events and I want to measure how long it takes to process all requests. I implemented it the following way though if there is any way to avoid doing the loop in scenario2 please share it with me.

class SettlementsSimulation extends Simulation {
  setUp(
    sendFundsRequestsScn.inject(
      constantUsersPerSec(2) during (2 seconds)
    ),
    triggerScriptScn.inject(
      atOnceUsers(1)
    )
  ).protocols(Settlements.jmsConfig, AutomationProperties.httpConf)
}

  lazy val sendFundsRequestsScn: ScenarioBuilder = scenario("Send Funds Requests")
    .feed(csv("cards.csv").circular)
    .feed(customFeeder)
    .exec(jms("SendMessage")
      .requestReply
      .queue(fromBoQueue)
      .replyQueue(toBoQueue)
      .textMessage(ElFileBody("FundsRequest.json"))
    )
    .exec { session =>
      fundsRequests = fundsRequests + 1
      session
    }

  lazy val triggerScriptScn: ScenarioBuilder = scenario("Trigger End-Of-Period script")
    .asLongAs(session => fundsRequests < 5) {
      doIf(session => fundsRequests == 4) {
        exec(
          http("Trigger End-Of-Period script")
            .post("/pmstatus")
            .body(StringBody("{\"command\": \"run\", \"parameters\": [\"settlement_ci\"]}"))
            .check(
              status.in(200)
            )
        )
      }
        .doIf(session => fundsRequests == 4) {
          exec { session =>
            fundsRequests = fundsRequests + 1
            println("Finishing scenario: " + fundsRequests)
            session
          }
        }
       // .exitHereIfFailed
        .pause(1 second)
    }

  var fundsRequests = 0

}

maybe using rendezvous? https://gatling.io/docs/2.3/general/scenario#rendezvous

Please use up-to-date links, eg https://gatling.io/docs/current/general/scenario/#rendezvous

Gatling 2 is no longer maintained.

I tried RendezVous but it stops all X users in scenario1 and then they all execute scenario2 while I want it to be done only once. I spent some more time and improved the loop in scenario2. I didn’t find any other way of implementing this test. It would be nice to have a feature allowing to define the sequence of scenarios in setUp() block


var continue: Boolean = true
lazy val triggerScriptScn: ScenarioBuilder = scenario("Trigger End-Of-Period script")
  .asLongAs(session => continue) {
    doIf(session => fundsRequests == 4) {
      exec(
        http("Trigger End-Of-Period script")
          .post("/pmstatus")
          .body(StringBody("{\"command\": \"run\", \"parameters\": [\"settlement_ci\"]}"))
          .check(
            status.in(200)
          )
      )
        .exec { session =>
          continue = false
          println("Finishing scenario, processed FR: " + fundsRequests)
          val sqs: SQSConsumer = new SQSConsumer