while-loopjmeterrequesthttp-response-codesextractor

Jmeter Retry Request if failed or ResponseCode not equal to 200


I have a CSV File with hundreds of records which I am using in the HTTP Sampler with Multiple Threads now sometime or multiple threads returns an error which I am OK but I want to retry in case we don't have ResponseCode 200 which I am extracting but not sure how to retry just that Request only and also I want to limit the tries to 5

I have tried using the while controller with Counter but somehow not able to get this right. Please help.

This is what I have tried enter image description here enter image description here enter image description here enter image description here enter image description here


Solution

    1. You need to define the Exported Variable Name in the Counter otherwise it doesn't make any sense:

      enter image description here

    2. You need to use vars shorthand for JMeterVariables class instance in your __groovy() function to get both Counter and Success variables values

      ${__groovy(vars.get('Status') != 'Success' && (vars.get('Counter') as int) < 5,)}
      
    3. Since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language so consider replacing your Beanshell Assertion with JSR223 Assertion