How to use feeder supplier for more than a value in Java version

Hello Gatling people, in the company I work at we are trying to migrate from Gatling-Scala version 3.6 to Gatling-Java 3.9.
I came through this issue where I’m unable to feed multiple data with a normal feeder, here is a sample code from the Scala version:

  val feeder_US = Iterator.continually(Map(
    "billing_address_Digital" -> "888 7th ave",
    "billing_city_Digital" -> "New York",
    "State_Digital" -> "NY",
    "zip_online_Digital" -> "10106",
    "billing_address_Studio" -> "46-024 Kamehameha Hwy",
    "billing_city_Studio" -> "Kaneohe",
    "State_Studio" -> "HI",
    "zip_online_Studio" -> "96744",
    "Market" -> "en-US",
    "local" -> "US",
    "randstring" -> ("US" + System.currentTimeMillis),
    "TimeZone" -> "-05:00",
    "plan_Digital" -> "digital",
    "plan_Studio" -> "studio"

and here is a Java version of the feeder but it only detects the first value in the rest of the script:

static Iterator<Map<String, Object>> feeder_US =
    Stream.generate((Supplier<Map<String, Object>>) () -> {
        String Level =  "info";                      
        String billing_address_Digital =  "888 7th ave";
        String billing_city_Digital =  "New York";
        String State_Digital =  "NY";
        String zip_online_Digital =  "10106";
        String billing_address_Studio =  "46-024 Kamehameha Hwy";
        String billing_city_Studio =  "Kaneohe";
        String State_Studio =  "HI";
        String zip_online_Studio =  "96744";
        String Market =  "en-US";
        String local =  "US";
        String TimeZone =  "-05:00";
        String plan_Digital =  "digital";
        String plan_Studio =  "studio";
        String randString =  ("US" + System.currentTimeMillis());
        return Collections.singletonMap("Level ", Level );
        } ).iterator();

How to feed all of those values with the Java version?


but it only detects the first value in the rest of the script

What do you mean exactly? How did you jump to this conclusion?

You can see with the example bellow that this kind of feeder works as expected:

public class FooSimulation extends Simulation {

  private static final AtomicInteger count = new AtomicInteger();

  private static final Iterator<Map<String, Object>> feeder =
    Stream.generate(() -> Collections.singletonMap("count", (Object) count.getAndIncrement())).iterator();

  ScenarioBuilder users = scenario("Users")
        .exec(session -> {
          return session;


I meant when using that feeded data later when building APIs for example I use

.get("https://something/#{Market }/something/#{TimeZone}")

in this instance only Market would be read, and I will get error that TimeZone isn’t defined.

You’re providing inconsistent data, it’s very hard to help you.

.get(“https://something/#{Market }/something/#{TimeZone}”)

First, there’s a whitespace in #{Market } so there’s no way it gets properly replaced if the actual key doesn’t have this whitespace.

return Collections.singletonMap("Level ", Level );

Then, as you’re only setting the Level key in your Map, there’s not way anything than #{Level} gets replaced.

Why are you using Collections.singletonMap? You should be creating HashMaps and put all your key-value pairs in there.

Thank you @slandelle, I was able to solve it this way to feed multiple data

public static Iterator<Map<String, Object>>  Demo=
            Stream.generate((Supplier<Map<String, Object>>) () -> Map.of(

          "local" , "US",
          "test" , 1 ,
          "test2" , "demo123" ,
          "randString" , ("US" + System.currentTimeMillis())