Gatling Java Unique ID generation

Hi Team ,

I want to generate unique numbers within a range to create Ids to be used in my XML file, Unfortunately ```
#{randomLong(2147483648,2147483658)}"
this Gatling EL function generating the random numbers for me , Can someone have any solution handy for this c, To generate unique ids . to be used in ELFileBody.

You don’t explain what your problem is and a part of your sentence is missing.
Please properly explain how the out-of-the-box feature doesn’t work for you so people can help you.

Could you describe more about your use case ?

I am understanding that “unique” mean you don’t want the number to be reuse in any case later on.
If that’s the case, then you have to define a way to save the number generated from using #{randomLong(2147483648,2147483658)} Maybe save to a CSV file ?

Then you need to write a method to check the CSV if it’s containing the ID.

Pseudo-code to simplify

when 
        #{randomLong(2147483648,2147483658)} //generate number

saveOutputInto(csvFile) //Method to save

then
      checkDuplicateID(csvFile) //Method to check the ID saved in the csv  
      when 
           //execute your logic below, maybe if else or something above

Hope this help !

Edit: You can also save into an array.

Hi @trinp , Thanks for responding ,

I am already passing a CSV feeder to my scenario , to the same scenario i need to generate the order id , In that case i believe we cant pass two feeders to a scenario , Please correct me if i am wrong ,

Thanks,
Lathem

Hi @Lathem , you can try Array there, but it is not advisable because it could affect the result.
Cheers!

Thanks for the suggestion @trinp , I have somehow managed to include another feed to 2nd scenario , That helped me

Thanks,
hema

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.