I am trying to make a dynamic query in a loop based on a earlier query fed to the scenario. Below is the code, I cannot seem to figure out how to get ${USER_ID} from the session…,
loop( chain
.feed( jdbcFeeder(“jdbc:hsqldb:/media/mobile/gatlingdb”,“SA”,"",“SELECT STUDENT_ID, GRADED_ITEM_ID FROM students WHERE teacher_id=’${USER_ID}’”).queue
)
I have tried pulling out ${USER_ID} via a concat, with no luck. I am printing the session and can see USER_ID is present.
Does anyone have any experience in this?
Hi Justin.
Feeders are loaded into memory before the simulation actually starts.
Therefore it is not possible to make dynamic feeders so far.
What you can do however is using a scala function to get data from the database if you really want to do this. 
What is your use case? So we can see if a feature could be implemented in this way 
Cheers,
Romain
Use case: Teachers login and grade students work. There are many students to the teacher and many gradable items per student.
My attempt was to query the database for teachers for the login. Loop after login and feed that loop with the students information based on the teacher logged in.
Let me know if I need to explain better.
I am going to look at the new redis feeder and see if I can better store my data for the load test.
Thanks Romain!
Hi there,
First of all, I’m not sure you’re heading in the right direction.
If what you want is to emulate user behavior, normal users don’t get their flow data from a database query, they get it from the pages theu get. Are you sure you can’t get the students list from a teacher page (capture the data from a regex for example) and then get the items list from a student page? I would expect your application to work like this, am I mistaking?
If you really want to poll the data from a data base, as Romain stated, you can’t use the current jdbcFeeder for this as it loads all the data in memory when simulation starts. Having this kind of jdbc dynamic query is something we could implement if we get enough community feedback asking for it.
Cheers,
Steph
2012/6/15 Justin Hohman <justinhohman@gmail.com>