简体   繁体   English

在Jmeter脚本中重试逻辑

[英]Retry logic in Jmeter script

How to implement retry logic in jmeter script based on the response code got in a request. 如何基于请求中获得的响应代码在jmeter脚本中实现重试逻辑。 Example if i am getting 409 response code, how i resend the same request for given number of iteration? 例如,如果我得到409响应代码,如何在给定的迭代次数下重新发送相同的请求?

  1. Put your request under the While Controller and use the following __groovy() function as the condition: 将您的请求放在While控制器下,并使用以下__groovy()函数作为条件:

     ${__groovy((vars.get('statusCode') == null || vars.get('statusCode').equals('409')) && ((vars.get('__jm__While Controller__idx') as int) < 5),)} 
  2. Add Regular Expression Extractor as a child of your request and configure it like: 正则表达式提取器添加为您的请求的子项,并将其配置为:

    在此处输入图片说明

  3. That's it, now your request will loop until response status code is 409 or 6th loop of the While Controller whatever comes the first. 就是这样,现在您的请求将一直循环直到响应状态代码为409或While控制器的第6个循环(无论先到者为准)。

More information: Using the While Controller in JMeter 详细信息: 在JMeter中使用While控制器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM