Random Number generator trouble


I am trying to generate random number below. It is generating same number over and over**.** please help me with this.

val r1 = new Random(10000000000)

val scn = scenario(“Load Test”)
.during(500 seconds)

http(“POST Activity “)
.headers(Map[String, String](“userid” → r1.nextLong().toString))
).pause(1 second)


rampUsers(1) over (60 seconds)


Many issues with your code:

  1. You’re passing a VALUE, that gets evaluated only once, when the Simulation is built. You have to pass a function, i.e. something that will wrap a block of code so that it will be evaluated every time needed.
  2. You should probably use a ThreadLocalRandom
  3. Why use headers for passing a single value? Just use header.

.headers(“userid”, session => r1.nextLong().toString)

Thanks Stephane. I implemented your suggestions and also removed .during() from the scenario, placed the steady time in setUp and it worked.