Richard Richard - 7 months ago 35
Scala Question

Push a message and then Poll for a result

We have two services, one which receives a message and a second which tells us when the message has been processed. I'm trying to cover this in a gatling test. Here's what I have so far but I'm struggling with the last bit..

scenario("push message and poll for result")
.group("push and check: group") {
.asLongAs(session => !session.contains("messageProcessed")) {
.check(, jsonPath("$.results[0].resultCount").saveAs("resultCount"))


My problem is resultCount will initially be zero so I want to keep polling until it becomes != 0. When this happens I thought I could set "messageProcessed" to something and then it would drop out of the loop.

Is there a way to do this? Thanks for your help.


this was the solution I used in the end

.asLongAs(session => getResultCount(session) == 0) {

and added this method:

def getResultCount(session: Session): Int = {