Do inter thread communication functions work in beanshell script?

422 views
Skip to first unread message

Anthony Lee

unread,
May 4, 2016, 6:07:37 PM5/4/16
to jmeter-plugins
I have beanshell script in the post processor to put download url to the queue:

String threadName = ctx.getThread().getThreadName();
int indexOfDash = threadName.indexOf("-");
String currentThreadCounter = threadName.substring(indexOfDash+1);
String fileUrl = vars.get("fileUrl");
String fileUrl1 = "";
String size = "";
${__fifoPut(currentThreadCounter, fileUrl)};
${__fifoSize(currentThreadCounter, size)};
${__fifoPop(currentThreadCounter, fileUrl1)};
print("put to queue " + currentThreadCounter + " fileUrl :"+fileUrl1 + "; size:" +size);



But the output shows that the fileUrl is empty and the size is empty too.

What's wrong? 

It works when I use jp@gc - Inter-Thread Communication PostProcessor; But I need to make the queue name dynamic so I need to use beanshell script.

Vincent Daburon

unread,
May 5, 2016, 10:36:47 AM5/5/16
to jmeter-plugins
Hi,
Another solution it is to use the HTTP Simple Table Server (STS) to put and get data between threads on same computer but also from multi computers.
Look at
http://jmeter-plugins.org/wiki/HttpSimpleTableServer/

The "Queue" is a "File" (or more precisely a linked list) on the Simple Table Server.

Regards.
Vincent D.

Andrey Pokhilko

unread,
May 6, 2016, 2:55:51 AM5/6/16
to jmeter-plugins
Hi,

The problem is that you using JMeter functions from BeanShell script text. JMeter functions are evaluated _before_ the script gets interpreted. And sometimes the result of this evaluation even cached in JMeter.

The correct approach in BeanShell would be to start working with FifoMap object directly, see https://github.com/undera/jmeter-plugins/blob/master/plugins/fifo/src/main/java/kg/apc/jmeter/modifiers/FifoMap.java


It's all pretty simple, should be easy for you. I saw people working like that without any problem.

--
Andrey

четверг, 5 мая 2016 г., 1:07:37 UTC+3 пользователь Anthony Lee написал:
Reply all
Reply to author
Forward
0 new messages