Mercy
Mercy

Reputation: 171

How to pass list of objects between thread groups in Jmeter

My first thread group parses a file and stores all the lines in a List. The second thread group should retrieve objects from the List one by one and send HTTPS request. Now the problem, how to make the list of objects (not just a property value) between thread groups Appreciate any help.

Upvotes: 1

Views: 3892

Answers (1)

Dmitri T
Dmitri T

Reputation: 168207

You can use Beanshell Test Elements and bsh.shared namespace to share variables across thread groups

In first thread group after parsing:

bsh.shared.myList = myList;

In second (or whatever thread group)

List myList = bsh.shared.myList;

See How to use BeanShell: JMeter's favorite built-in component for more scripting options.

If you use different scripting language (not Beanshell) - it is still possible to use props pre-defined variable which stands for JMeterProperties instance. JMeterProperties is basically an instance of java.util.Properties so you can store any object in there like:

In first thread group:

List myList = new ArrayList();
//do what you need with the list
props.put("myList", myList);

In second thread group:

List myList = props.get("myList");
// do what you need with the list 

Upvotes: 3

Related Questions