JMeter在Spring Service How-to中获取jdbc请求数据并使用http post请求发送每个数据 [英] JMeter get jdbc request data and send each with http post request in a spring service how-to

查看:167
本文介绍了JMeter在Spring Service How-to中获取jdbc请求数据并使用http post请求发送每个数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用过jmeter,我尝试从jdbc请求中获取一些数据,并在带有http请求的spring服务中发送它们.

I used jmeter recently and I try to get some data from a jdbc request and send them in a spring service with http request.

让我更具体地解释.

我使用以下查询:

SELECT MEMBER_ID, 
       PERSON_NAME, 
       PERSON_SURNAME 
FROM MEMBER, 
     PERSON 
WHERE CDT_MEMBER_ID = CDT_PERSON_ID

从上述请求中,将值插入以下变量中:id,name,surname,其中我已在JDBC请求控制面板的变量名称"字段中定义. (在每个变量中返回10个值,因此我将它们视为数组)

From the above request the values inserted in these variables: id, name, surname, where i have define in "Variables names" field of JDBC request control panel. (in each variable returned 10 values, so i treat them as arrays)

然后我使用"For Each"控制器尝试循环到值中,但我不能. 进入对于每个"控制器面板,如果我将其设置为输入变量前缀"(例如,id),并将其设置为输出变量名称"变量,则循环将正常工作,然后使用内部的http请求,我将${variable}发送到春季服务.

Then I use a "For each" controller tried to loop into the values but I can't. Into the "For each" controller panel, if I set as "Input variable prefix" (e.g.) the id and as "Output variable name" variable, loop works correctly and then with an inner http request I send the ${variable} at the spring service.

但是我想每次都以字符串形式发送一行(id [i] +名称[i] +姓氏[i]).怎么办呢?

But I want to sent a row each time as a String (id[i] + name[i] + surname[i]). How can do this?

我还尝试编写一些脚本来使用beanshell预处理程序定义此字符串,而没有任何效果.

I also try to write some scripts to define this string with beanshell pre-processor without any effectiveness.

推荐答案

好吧,据我所知,我必须在"JDBC Request"和"ForEach Controller"之间使用"BeanShell Sampler". 然后,使用beanShell脚本获取数组的长度,编写脚本:

Ok, as far as I have realised, I have to use a "BeanShell Sampler" between "JDBC Request" and "ForEach Controller". Then using beanShell script I take the length of the arrays, scripting:

Integer x = Integer.parseInt(vars.get(dataId_#)); 

在for循环中,我将数据插入到String数组中,如下所示:

and in a for loop i insert the data in a String array like these:

String[] dataArray = new String[x];
for (i = 0; i < x; i++) {
vars.put("dataArray_" + i, vars.get("dataId_" + i) + " " + vars.get("name_" + i) + " " + vars.get("surname_" + i));
}

这篇关于JMeter在Spring Service How-to中获取jdbc请求数据并使用http post请求发送每个数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆