# Sessions and pauses

**URL:** <https://community.gatling.io/t/sessions-and-pauses/580>\
**Category:** Gatling (Open-Source)\
**Created:** [September 13, 2013, 1:00pm UTC](https://community.gatling.io/t/sessions-and-pauses/580 "2013-09-13T13:00:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Casey\_Sybrandy](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Casey\_Sybrandy](https://community.gatling.io/u/Casey_Sybrandy)\
**Post date:** [September 13, 2013, 1:00pm UTC](https://community.gatling.io/t/sessions-and-pauses/580/1 "2013-09-13T13:00:32Z")

</div>

Hello,

I’m trying to use Gatling 1.5.2 and one of the things I’d like to do is have how long I pause for a URL be dynamic. So, I have something like this:

val scn = scenario(“Test Scenario”)  
.feed(userFeeder)  
.feed(csv(fname).random)  
.pauseCustom(() =\> java.lang.Long.parseLong("${pause}"))  
.exec(  
http(“Req 1”)  
.get("…")  
.check(status.is(200))  
)

The “userFeeder” has two values: “user”, which is the username, and “pause”, which is how long I want to pause for each URL. However, I can’t seem to access the value that’s in “pause” when I try to execute the pause. In this case, and in a simpler one with the normal “pause” method, I get a parse exception.

How can I do this? Is this even possible? The documentation seems to indicate that something like I did should be possible, but it’s not working. I’d also love to be able to do something similar for how often I repeat an action as well.

Thanks.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [September 16, 2013, 3:15pm UTC](https://community.gatling.io/t/sessions-and-pauses/580/2 "2013-09-16T15:15:48Z")

</div>

EL expressions can’t be parsed implicitly inside a function.  
And pauseCustom, as stated by its signature, can’t access the session, so cannot retrieve user data.

You can convert your data from String to Long directly in your feeder:

val feeder = csv(fname).map { record =\>  
record.map {  
case (“pause”, value) =\> “pause” → value.toLong  
case entry =\> entry  
}  
}.random

This is easier with Gatling 2 as feeders have a transform method for this purpose.

---

<div class="post-metadata">

**Author:** ![Casey\_Sybrandy](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Casey\_Sybrandy](https://community.gatling.io/u/Casey_Sybrandy)\
**Post date:** [September 16, 2013, 4:38pm UTC](https://community.gatling.io/t/sessions-and-pauses/580/3 "2013-09-16T16:38:18Z")

</div>

Hello,

Thanks, but that doesn’t seem to resolve the issue. I’m now getting a couple compilation issues. Here’s the current code:

package test

import com.excilys.ebi.gatling.core.Predef.\_  
import com.excilys.ebi.gatling.http.Predef.\_  
import com.excilys.ebi.gatling.jdbc.Predef.\_  
import com.excilys.ebi.gatling.http.Headers.Names.\_  
import akka.util.duration.\_  
import bootstrap.\_  
import [scala.io](http://scala.io).\_

class TestSim extends Simulation  
{  
val numUsers = Integer.getInteger(“users”, 10);  
val rampUp = java.lang.Long.getLong(“ramp”, 0L);  
val fname = System.getProperty(“ccodes”);

// The next two lines copy data from a file and put it into an array.  
/_val cCodes = new collection.mutable.ArrayBuffer[String]_/  
/_Source.fromFile(fname).getLines.foreach(code =\> cCodes += code)_/

val httpConf = httpConfig.baseURL(“[http://localhost:8080](http://localhost:8080)”)  
.acceptHeader(“application/json”)  
/_val userFeeder = Array(Map(“user” → “foo”, “pause” → 1),_/  
/\* Map(“user” → “bar”, “pause” → 2),_/  
/_ Map(“user” → “baz”, “pause” → 3)).random\*/  
val userFeeder = csv(“user.dat”).map { record =\>  
record.map {  
case (“delay”, value) =\> “delay” → value.toLong  
case entry =\> entry  
}  
}.random

val scn = scenario(“Test Scenario”)  
.feed(userFeeder)  
.feed(csv(fname).random)  
.pause(delay)  
.exec(  
http(“Req 1”)  
.get("…")  
.check([status.is](http://status.is)(200))  
)

setUp(scn.users(numUsers).ramp(rampUp).protocolConfig(httpConf))  
}

The errors I’m getting are:

[error] /home/dev/rmt/volt-getaor/src/main/scala/VoltGetAor.scala:31: value random is not a member of Iterator[scala.collection.immutable.Map[java.lang.String,Any]]  
[error] possible cause: maybe a semicolon is missing before `value random’?  
[error] }.random  
[error] ^  
[error] /home/dev/rmt/volt-getaor/src/main/scala/VoltGetAor.scala:40: not found: value delay  
[error] .pause(delay)  
[error] ^

I’ll apologize now if it’s my own stupidity, but this was thrust upon me late last week and I never programmed in Scala before.

Thanks.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [September 16, 2013, 5:10pm UTC](https://community.gatling.io/t/sessions-and-pauses/580/4 "2013-09-16T17:10:13Z")

</div>

There’s a toArray missing before random.

---

<div class="post-metadata">

**Author:** ![Casey\_Sybrandy](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Casey\_Sybrandy](https://community.gatling.io/u/Casey_Sybrandy)\
**Post date:** [September 16, 2013, 5:31pm UTC](https://community.gatling.io/t/sessions-and-pauses/580/5 "2013-09-16T17:31:15Z")

</div>

Hopefully last question: how do I access the value then in the “.pause()” call? It looks like I can simply access the userFeeder array and access a value, but then I wouldn’t know if that value is the one being referenced somewhere else in the session. The examples that come with Gatling assume that all values coming out of a feeder are accessed in strings, which is not the case here.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [September 16, 2013, 6:44pm UTC](https://community.gatling.io/t/sessions-and-pauses/580/6 "2013-09-16T18:44:43Z")

</div>

Ha, I’m very sorry: I realize that Gatling 1 doesn’t support dynamic pauses, only Gatling 2 does.  
If that’s a feature you really need, you’ll have to migrate.
