[英]Jmeter : using While Controller for failed request retries, ThreadGroup loop count not working
I added a While Controller and try to send this request multiple times in case if it doesn't work the first time or simply just trying to implement retry logic.我添加了一个 While Controller 并尝试多次发送此请求,以防它第一次不起作用或只是尝试实现重试逻辑。
Thread Group configurations are:线程组配置为:
Issue: As per thread group config, it should run ( while controller * 10 ) but it only runs 1 time.问题:根据线程组配置,它应该运行(而 controller * 10 )但它只运行 1 次。
In my Bean PostProcessor:在我的 Bean 后处理器中:
vars.remove("response_code");
vars.put("response_code",prev.getResponseCode());
In WhileController:在 WhileController 中:
${__jexl3(${response_code} != 200 && ${retries} < 3,)}
Any help would be appreciated!任何帮助,将不胜感激!
On 2nd iteration of your Thread Group your ${response_code}
variable becomes 200
therefore it will not enter the While Loop.在线程组的第二次迭代中,您的${response_code}
变量变为200
,因此它不会进入 While 循环。
The solution is to reset both ${response_code}
and ${retries}
variables to 0
解决方案是将${response_code}
和${retries}
变量都重置为0
Put the following code into "Script" area:将以下代码放入“脚本”区域:
SampleResult.setIgnore() vars.put('response_code', '0') vars.put('retries', '0')
Also be aware that starting from JMeter 3.1 you shouldn't be using Beanshell so consider migrating from the Beanshell PostProcessor to the JSR223 PostProcessor .另请注意, 从 JMeter 3.1 开始,您不应该使用 Beanshell ,因此请考虑从 Beanshell PostProcessor 迁移到JSR223 PostProcessor 。 More information: Apache Groovy - Why and How You Should Use It更多信息: Apache Groovy - 为什么以及如何使用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.