Concurrency errors when using scala iterators

I don’t use the gatling feed functionality much, and less and less as time goes on, because they don’t usually match my requirements. So I mostly manually feed stuff into the session, and I use a lot of circular iterators. Mostly this is ok, though I’ve had occasional errors. But now, I had to make some changes similar to what is described at the end of the feeder documentation. I have one feed that determines the tenant, while all the other feeds are managed separately per tenant. So first I feed in the tenant, and based on the tenantI feed in the rest of the data. The tenant feed is generated by first logging in to each organization, and saving the access token for each tenant (see load method below):

Hi Jonathan,

What you’re doing can’t simply work. It’s not a matter of Scala but one of concurrent programming.
Just like Java Iterators, Scala ones are not thread-safe.

But how can I feed something into a scenario when the data for the feed is created at the beginning of the simulation? I use custom rendez-vous points to allow a setup simulation to run before the other simulations, and this setup is responsible for creating the data for this feed. But the waiting scenarios load the data before the setup completes, while the feed is still empty.

Do you have any other suggestions of how to make this work (other than using sbt)?

Use concurrent structures (Java's java.util.concurrent package).
ConcurrentLinkedQueue for example.

*Stéphane Landelle*
*Lead developer*