Richard Richard - 1 year ago 70
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.

Answer Source

this was the solution I used in the end

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

and added this method:

def getResultCount(session: Session): Int = {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download