I should run an remote API in Nifi and response is a Json like this:
{"data":[{...}, {...}, ...],"nextPage":"http://example.com/nextCall"}
I must continue to call the API and accumulate "data" until nextPage becomes null.
I have implemented it by using attributes and DistributedCacheServer, but it is not optimum, because data has about 1000 element and every element is a Json with several keys and values.
Updated Feb 16 2019:
This is my work flow:
This is my Multipage Handler:
https://gist.github.com/behrouz-s/01f9fe1c09ac9d54d0adf3cdd011ea1d
the idea:
at input you have a valid json as content (for example null), target url in some attribute,
cycle point: set request fragment.identifier=${UUID()} , and fragment.count=2
you transfer this file in two directions:
fragment=0 goes to merge and waits there the second file that will contain http response
fragment=1 goes through invokehttp
merge uses binary concat and always waits for 2 files
if next url is valid goto 2
Related
May i know how to achieve this scenario in JMeter.
Requirement 1 : Request 1 should execute for 15 mins, once 15 mins crossed request 2 should execute and request 1 to be stopped.
Requirement 2 : In request 1, we need to capture all dynamic value and store it some place and same dynamic value we should use it as request body for request 2. We like to run large numbers of users. Not sure, how to store all the response in some files or other alternatives.
Ex : Request 1 - > Trigger -> Store response somewhere(15 min run & 100 iteration) - stopped
Request 2 - > Trigger after 15 min - Execute request with above 100 iteration response)
Either take a look at Runtime Controller, using this guy you can choose how long its child(ren) will be run or just put your requests 1 and 2 into separate Thread Groups
If you want to store full responses into a file take a look at:
Post-Processors to capture the required part of the response into a JMeter Variable
Sample Variables property to tell JMeter to save this variable into .jtl results file
Flexible File Writer if you want to write the values into a separate file
I have been receiving this error message on particular request - "Value cannot be null. Parameter name: source".
My Scenario is that 1 user will be transacting 5 transaction (Search and Remit). I'm targeting to run 650 Users to 3250 Transaction. The problem is that one particular request which is getting details from the DB, some data is passed but mostly are the mentioned error message above.
I Have 2 CSV Config, 1 from Users, the 2nd is for the Data where the second csv is inside the Loop Controller.
Your application tells you that the request is not correct, it expects a value and you're failing to provide the value. Use Debug Sampler and View Results Tree listener combination to validate the values of the JMeter Variables which are being sent for successful and not successful requests, it might be a test data issue, for example an extra comma in the CSV file will make CSV Data Set config "think" that this is the delimiter for the next column.
i'm setting a test plan running this thread groups sequentially:
Execute request A using 10 threads, 500 loops.
Execute request B using 10 thread, 500 loops, and the output from step 1.
My problem is this:
On each request A, i receive an ID that i need to pass to request B.
What is the best way to store all the IDs and then use them on step 2?
At this time, i am "JSonExtracting" each ID from response and store on a CSV file to pass to step 2.
The problem is the concurrence of the treads. Some times i got empty spots on the file or concatenated strings which will produce an error on step 2.
I was not able to store this to an array variable to use on step 2.
To write the IDs to a file, i am using this code on a BeanShell Listener inside my threadGroup. I strongly believe this is not the most correct way to do it.
f = new FileOutputStream("${DocumentIdsFile}", true);
p = new PrintStream(f);
p.println("${DocumentId}");
p.close();
f.close();
log.info("Id: ${Id}");
How can i solve this concurrence problem?
If you receive an ID at the request A, just use it in request B, passing it throug variable:
Parse ID value in request A response using one of the Post-Processors to store it in variable, for example "ID".
Use it's value in your request B as a parametr:
GET https://myserver.com/myapp/getSomethig/${ID}
I just wanted to extract value from the response body of thread1(1st thread am running once by passing number of threads and loop count 1 each) and need to pass same for the 2nd thread(2nd thread am running multiple times by passing number of threads 10).
This is my response body from Thread1.
{"availablePhoneNumbers":["3052191421","3052192726","3052192566","3052195123","3052194493","3052199654","3052194684","3052199164","3052190020","3052190352"]}
i just wanted to pick the first data 3052191421 and wanted to run in thread2 for all the HTTP requests.
then 2nd data 3052192726
then 3rd data and so on.
Could you please get the solution for this?
Thanks in advance..
Extract first number from the response. This can be done using JSON Extractor configured like:
Names of created variables: number
JSON Path Expressions: $.availablePhoneNumbers[0]
Later on you will be able to use __longSum() function in order to:
add 1 to ${number} variable
return the value
save the result back into the ${number} variable
Demo:
My test plan looks like this
TEST_PLAN
-Thread_group: (user: 1, ramp: 1, loop:70)
--Loop_Controller_1(loop:1)
--Loop_Counter
-- HTTP request1: go to page_1
-IF_Controller1 ( Loop_Counter=5)
-- HTTP request2: go to page_2
-IF_Controller2 ( Loop_Counter=67)
-- Loop_Controller_2 (loop:3)
--- HTTP request3: go to page_2
Here the condition is based on the Loop_Counter, if loop_counter is 5, IF_Contoller1 is executed. When loop_counter is 15, If_controller2 is met, Loop_controller_2 should be executed for 3 loops. All 3 http request inputs are read from 3 different CSV files.
When executed, http request 1 is invoked only 4 times, not sure how this enter code herenumber is achieved.
Is this correct way of implementation, or anything missing/wrong?
Please help!
Implementation looks good, however scope of CSV Data Set Config matters.
I would recommend adding any of your CSV Data Config Element as a child of the request you're trying to parametrize. Also check Recycle on EOF, Stop thread on EOF and especially Sharing Mode parameters.
See Using CSV DATA SET CONFIG guide for more details.
As an option you can post your .jmx file and any CSV files used somewhere so it would be more clear what's going on in your case.