Daniel Protopopov
Daniel Protopopov

Reputation: 7246

jMeter - Re-use response data in follow-up requests

We have a service that works the following way:

First, a request with search parameters is sent, for which we get back a searchId. This searchId is then used to continue fetching information until service response it has no more data left (hasMore parameter becomes "false").

The question is this - I have set up jMeter to send first requests, but not certain how then to keep sending requests in parallel for each response in the Thread Group, and need your advice on it. My thought was to set up another Thread Group since I cannot set it inside the first one, but then how do I get access to responses and process them in parallel?

EDITED:

This is what I ended up with. First Beanshell Sampler extracts searchId and hasMore and puts it into vars. Second Sampler extracts hasMore and again puts it into vars, overwriting the first. At the end, the While loop worked as intended, using ${__javaScript("${hasMore}" == "1",)}.

Project Test Plan

Upvotes: 0

Views: 973

Answers (2)

Dmitri T
Dmitri T

Reputation: 168157

I would recommend designing your test as follows:

  • Request to get searchId
  • While Controller with condition like ${__javaScript("${hasMore}" != "false",)}

This way "fetch information" requests will be executing until hasMore parameter becomes false. See Using the While Controller in JMeter article for more details.

Upvotes: 1

Ori Marko
Ori Marko

Reputation: 58872

I suggest 2 Thread group

First Thread group:

Save searchIds in file (JSR223 Sampler) or database (JDBC Sampler) with key as counter (1,2,...) and value as the searchId value

Save a number of IDs in property ${__setProperty(threadCount,${counter})}.

Second Thread group:

In definition - Number of thread use ${__P(threadCount)}

Read from file (JSR223 Sampler) or database (JDBC Sampler)

using ${__threadNum} as key get the relevant searchId you need

Upvotes: 0

Related Questions