title: JMeter - How to call request until received response containing specific attributes?
body: <h1><strong>Situation</strong></h1>
  <p>I am preparing a JMeter test plan to test against AWS Device provisioning MQTT API.
  The flow is:</p>
  <ol>
  <li>connect to AWS IoT Core endpoint</li>
  <li>make <code>CreateKeysAndCertificate</code> request until receiving a success response as the below one (as there is a 10 times requests per second quota limit in aws)</li>
  </ol>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;certificateId&quot;: &quot;string&quot;,
      &quot;certificatePem&quot;: &quot;string&quot;,
      &quot;privateKey&quot;: &quot;string&quot;,
      &quot;certificateOwnershipToken&quot;: &quot;string&quot;
  }
  </code></pre>
  <ol start="3">
  <li>extract <code>certificateOwnershipToken</code> from the success response to make <code>RegisterThing</code> request until receiving a success response (as there is a 10 times requests per second quota limit in aws)</li>
  </ol>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;certificateOwnershipToken&quot;: &quot;string&quot;,
      &quot;parameters&quot;: {
          &quot;string&quot;: &quot;string&quot;,
          ...
      }
  }
  </code></pre>
  <p>If the no. of requests exceeds AWS quota limits, the response would be as the below one</p>
  <pre><code>{
      &quot;statusCode&quot;:412,
      &quot;errorCode&quot;: &quot;Throttled&quot;,
      &quot;errorMessage&quot;: &quot;Rate limit exceeded&quot;
  }
  </code></pre>
  <h1>Problems in my test plan</h1>
  <p>My test plan is as below pics, there are two problems</p>
  <ol>
  <li><p>I want to make 500 success requests, but now the test plan only make 500 requests(including those fails)</p>
  </li>
  <li><p>I need to use <code>certificateOwnershipToken</code> from each success request for each thread to make <code>RegisterThing</code> request, but now <code>certificateOwnershipToken</code> would be the default value <code>not_found</code> even if <code>CreateKeysAndCertificate</code> request is successful</p>
  </li>
  </ol>
  <p>What are the problems in my test plan and how to fix them? Thank you.</p>
  <p><a href="https://i.stack.imgur.com/OT7fE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OT7fE.png" alt="My test plan" /></a></p>
  <p><a href="https://i.stack.imgur.com/IbWbi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IbWbi.png" alt="User defined variable" /></a></p>
  <p><a href="https://i.stack.imgur.com/jjYUS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jjYUS.png" alt="thread group properties" /></a></p>
  <p><a href="https://i.stack.imgur.com/aFfHp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aFfHp.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/tzS62.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tzS62.png" alt="enter image description here" /></a></p>
  <p><a href="https://docs.aws.amazon.com/iot/latest/developerguide/fleet-provision-api.html#create-keys-cert" rel="nofollow noreferrer">AWS Device provisioning MQTT API docs</a></p>
  <p><a href="https://github.com/xmeter-net/mqtt-jmeter" rel="nofollow noreferrer">JMeter MQTT plugin github page</a></p>