def getrandomNo(): String = {
return ((rnd.nextDouble() * (1000000.0)).toLong).toString
}
scenario("scn getart).during(test_duration minutes) {
exec(actionBuilder = http("req getart")
.post(apiurl)
.header("txn-id", getrandomNo()+"_getart")
.body(apibody)
}
In the above code sample trying to generate unique txn-id for each request. However, observed that it is reusing the same number causing duplicates. Also I tried using the following to generate based on current time still it is causing duplicate when more than 1 requests are fired within 1second.
def getTxnId(): String = {
"PerfTest_" + System.currentTimeMillis().toString+ getrandomNo()
}
Any alternate solutions to generate unique ids for each requests irrespective of concurrency?
Thanks in advance.