[英]How i can receive variable from another thread in Jmeter
in the first thread, I received JSON (format - {"id":6054,"name":"Jmeter created chat","description":"jmeter created test"} )在第一个线程中,我收到了 JSON (格式 - {"id":6054,"name":"Jmeter created chat","description":"jmeter created test"} )
I want to use it in the second thread variable '6054'我想在第二个线程变量'6054'中使用它
I use BeanShell Assertion with code: ${__setProperty(("id":"(.+?)"), ${chat_id)};
我使用带有代码的 BeanShell 断言:
${__setProperty(("id":"(.+?)"), ${chat_id)};
but it, of course, doesn't work, please tell me the right way..但它当然不起作用,请告诉我正确的方法..
many thanks非常感谢
So所以
Remove your Beanshell Assertion删除你的 Beanshell 断言
Add JSR223 PostProcessor as a child of the request which returns the above response添加JSR223 PostProcessor作为返回上述响应的请求的子项
Put the following code into "Script" area:将以下代码放入“脚本”区域:
props.put('chat_id', new groovy.json.JsonSlurper().parse(prev.getResponseData()).id as String)
In 2nd Thread Group access the value using __P() function as:在第二个线程组中,使用__P() function访问值:
${__P(chat_id,)}
Demo:演示:
More information regarding what these prev
and props
guys mean can be found in the Top 8 JMeter Java Classes You Should Be Using with Groovy article有关这些
prev
和props
的意思的更多信息可以在前 8 个 JMeter Java 类你应该使用 Groovy 文章中找到
PS You may find Inter-Thread Communication Plugin easier to use PS您可能会发现线程间通信插件更易于使用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.