Reputation: 1426
I have a JMeter script which makes requests to 5 different endpoints. If there's an error, that thread should be stopped.
However, I would like to retry the request to the 3rd endpoint 3 times before stopping the thread.
Here is what my script looks like:
Since I checked option Stop thread under Thread Group, if the first request to the 3rd endpoint fails, the thread stops and no retries are made.
If I check Continue, then the retries to the 3rd endpoint work as intended, but the thread doesn't stop if the requests to the other endpoints fail.
I also tried to add the following Groovy script to the JSR223 PostProcessor, but it didn't work:
if (prev.isStopThread()) {
prev.setStopThread(false)
}
I'd appreciate any help I can get.
Thank you!
Upvotes: 0
Views: 1868
Reputation: 168052
Just set "Action to be taken after a Sampler error" to Continue
in the Thread Group to prevent threads from stopping.
If you decide to stop the thread you can do it in 2 ways:
Via Flow Control Action Sampler (in conjunction with the If Controller)
Via any of your JSR223 Test Elements as
prev.setStopThread(true)
You don't even need a counter, since JMeter 5.0 While Controller exposes current iteration via __jm__While Controller__idx
pre-defined variable
Upvotes: 1