Aks.Soms
Aks.Soms

Reputation: 137

Jmeter, execute HTTP request again after some sleep time

I am new to jmeter. Writing script as below:

Thread group1: Token generation

Thread group2: Use token created in Thread group1 and call API.

Need to execute Thread group1 after every 10 mins, so that new token is generated and it is used by Thread group2.

Script structure: Script structure

Upvotes: 0

Views: 451

Answers (2)

Dmitri T
Dmitri T

Reputation: 168147

  1. In order to implement a 10 minutes "sleep" Add a Flow Control Action sampler (earlier was Test Action) to 1st Thread Group and configure it to Pause the thread for 600000 milliseconds - 10 minutes

    JMeter Test Action Flow Control

  2. In order to pass token value from one Thread Group into another - use __setProperty() function in 1st thread group to convert JMeter Variable into a JMeter Property and __P() function in 2nd thread group to read the token value.

According to JMeter Best Practices you should always be using the latest JMeter version so consider migrating to JMeter 5.0 (or whatever the latest version available at JMeter Downloads page) as soon as possible.

Upvotes: 2

Aks.Soms
Aks.Soms

Reputation: 137

Below solution worked for me:

In Thread group2 call the API.

Then extract the status code using Regular Expression Extractor.

Regular Expression Extractor

Add if controller.

if controller

NOTE: The only drawback is that, when a request fails then only new token is generated.

Upvotes: 0

Related Questions