Search code examples
scalagatling

Run http tests until AMQ msgs consumed


We're running Gatling/Scala to load test an application in the following manner:

  1. Post a ton of messages to AMQ.
  2. Run a number of REST calls while messages are being consumed.

The Gatling setup looks like this:

setUp(
    JmsScenario.run inject(atOnceUsers(events)) protocols(JmsScenario.jmsConnect),
    HttpScenario.run inject(constantUsersPerSec(httpThroughput) during(httpDuration)) protocols(HttpScenario.protocol),
)

But instead of using during(...) I'd like to use something like untilAmqMessageQueueIsEmpty(). Is there some (fairly easy) way to accomplish this?


Solution

  • Use asLongAs and call some custom code (in Java if you don't know Scala). https://docs.gatling.io/reference/script/core/scenario/#aslongas.

    // isAmqMessageQueueIsEmpty is something only you can code
    // It has to return a Boolean
    asLongAs(session => isAmqMessageQueueIsEmpty()) {
       ???
    }