# Using loops

**URL:** <https://community.gatling.io/t/using-loops/2531>\
**Category:** Gatling (Open-Source)\
**Created:** [September 15, 2015, 10:54am UTC](https://community.gatling.io/t/using-loops/2531 "2015-09-15T10:54:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harald\_Jensas](https://avatars.discourse-cdn.com/v4/letter/h/8baadc/32.png) [@Harald\_Jensas](https://community.gatling.io/u/Harald_Jensas)\
**Post date:** [September 15, 2015, 10:54am UTC](https://community.gatling.io/t/using-loops/2531/1 "2015-09-15T10:54:45Z")

</div>

Hi,

I am using gatling-jms, I want to use a repeat loop to have my test set up “n” number of queues that it is looping over.

Here is my code:

`

object multiqueue {  
val multiqueue2k = repeat(9, “count”) {  
val mqQueue = “PingPong” + “${count}”  
exec(jms(“2k Request Reply” + mqQueue).reqreply  
.queue(mqQueue)  
.replyQueue(mqQueue)  
.bytesMessage(ba2k)  
.property(“messageNbr”, \_ =\> ThreadLocalRandom.current.nextInt())  
)  
}  
}

`

The queue on the broker is created with name: “PingPong${count}”

Looking at Step 04: Looping in the documentation here: [http://gatling.io/docs/2.1.7/advanced\_tutorial.html](http://gatling.io/docs/2.1.7/advanced_tutorial.html) it looks like what I am trying to do should work?

//  
Harald

---

<div class="post-metadata">

**Author:** ![Abhinav\_Gogna](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Abhinav\_Gogna](https://community.gatling.io/u/Abhinav_Gogna)\
**Post date:** [September 16, 2015, 5:44pm UTC](https://community.gatling.io/t/using-loops/2531/2 "2015-09-16T17:44:48Z")

</div>

Have you tried it this way?

` `object multiqueue {` `val multiqueue2k = repeat(9, “count”) {` `exec(jms(“2k Request Reply ````PingPong ${count}``”).reqreply` `.queue(mqQueue)` `.replyQueue(mqQueue)` `.bytesMessage(ba2k)` `.property(“messageNbr”, \_ =\> ThreadLocalRandom.current.nextInt())` `)` `}` `}`

`
