asLongAs condition problem


I have defined a loop which is supposed to end once the current time is greater than a predefined value.

Before scenario:

val proposedEndTime = System.currentTimeMillis + (1601000)

Inside scenario:

.asLongAs(proposedEndTime > System.currentTimeMillis) {
exec(session => session.set(“sentOnTime”, System.currentTimeMillis))
.exec(ws(“ActualChatMessage”).sendText("""{“messageType”: “newChatMessage”, “you”: “${currentUser}”, “thirdParty”: “${currentThirdParty}”,
“sendTime”: “${sentOnTime}”, “message”: “Hello”}""")

The problem is that the loop is never stopping, as if there is no condition. Do you have some ideas of what may be the problem?

Thanks a lot.

Jamie Tabone

First, your condition is not a function but is static, so it’s only evaluated once, when the simulation is built.
You’d have to pass a function: .asLongAs(session => proposedEndTime > System.currentTimeMillis)

Then, assuming what you want to achieve is indeed the sample you provided, using a during loop would be way more simple:

Thanks a lot :slight_smile: I solved it now.

Jamie Tabone