# Polling for the second Request does not work

**URL:** <https://community.gatling.io/t/polling-for-the-second-request-does-not-work/4907>\
**Category:** Gatling (Open-Source)\
**Created:** [April 2, 2019, 2:00pm UTC](https://community.gatling.io/t/polling-for-the-second-request-does-not-work/4907 "2019-04-02T14:00:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AKSHETTY1982](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@AKSHETTY1982](https://community.gatling.io/u/AKSHETTY1982)\
**Post date:** [April 2, 2019, 2:00pm UTC](https://community.gatling.io/t/polling-for-the-second-request-does-not-work/4907/1 "2019-04-02T14:00:35Z")

</div>

Hi ,

Its been more than a week that i have failed to invoke a subsequent second GET call in my Scenario.  
The GET call is not being made .  
The scenario first does a POST request on a API which is asynchronous and starts to run a Job.  
I am required to make a second GET call to know the status of the job that was triggered by the first POST call.  
I am using the uniqueId ( UID) generated from the first POST call to know the latest status , using the GET call.  
Below is the implementation and i see that the GET call is not being invoked. I am starting to think if this is a Bug.  
The reason why i am think that this could be a Bug is because i am able to see the GET call being made when i replace the Polling with tryMax.  
just for your information , i have posted the implementation using tryMax at the Bottom.

```auto
val scn: ScenarioBuilder = scenario("Stress test scenario for records_included=All")
  .feed(feeder.customFeeder)
  .repeat(3, "counterName") {
    doWhile("$execState".equals("COMPLETED")) {
      exec(http("Submit Alerts for Execution").post("/_execute/?wait_for_completion_seconds=0")
        .body(StringBody(execution))
        .check(status.is(200))
        //.check(substring("COMPLETED").exists)
        .check(jsonPath("$.uid").saveAs("execUID")))
        .pause(1)
        .exec(session => {
          execUID = session("execUID").as[String]
          println("execUID ( Var ) :>>>>>>>>>>" + execUID)
          //println(session)
          session.set("temp","temp")
        })
        .exec(
          polling
            .every(15 )
            .exec(http("Retrieve Execution Status").get("/_execute/"+"${execUID}"+"?wait_for_completion_seconds="+TestConfig.duration)
              .check(status.is(200))
              .check(jsonPath("$.state").saveAs("execState"))
              .check(bodyString.saveAs("BODY"))
              .check(substring("COMPLETED").exists))
        )
        .exec(session => {
          val response = session("BODY").as[String]
          println(s"GET Response body ---- ***** : \n$response")
          session
        })
    }
  }
setUp(
  scn.inject(atOnceUsers(TestConfig.usersFile))
).protocols(httpConf)

```

```auto

```

```auto

```

```auto
Below is the implementation using tryMax.I am able to see the GET call being made using the below implementation.

```

```auto

```

---

<div class="post-metadata">

**Author:** ![AKSHETTY1982](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@AKSHETTY1982](https://community.gatling.io/u/AKSHETTY1982)\
**Post date:** [April 4, 2019, 11:02am UTC](https://community.gatling.io/t/polling-for-the-second-request-does-not-work/4907/2 "2019-04-04T11:02:05Z")

</div>

i would be very grateful if someone can help me with this.

---

<div class="post-metadata">

**Author:** ![AKSHETTY1982](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@AKSHETTY1982](https://community.gatling.io/u/AKSHETTY1982)\
**Post date:** [April 9, 2019, 3:22pm UTC](https://community.gatling.io/t/polling-for-the-second-request-does-not-work/4907/3 "2019-04-09T15:22:39Z")

</div>

I am still hoping that someone would explain why the GET request is not invoked during polling

---

<div class="post-metadata">

**Author:** ![AKSHETTY1982](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@AKSHETTY1982](https://community.gatling.io/u/AKSHETTY1982)\
**Post date:** [April 15, 2019, 6:15am UTC](https://community.gatling.io/t/polling-for-the-second-request-does-not-work/4907/4 "2019-04-15T06:15:29Z")

</div>

Hi Madhana,  
Can you help me with below.  
Regards  
Akshay

---

<div class="post-metadata">

**Author:** ![G\_Madhana\_Mohana\_Red](https://avatars.discourse-cdn.com/v4/letter/g/b38774/32.png) [@G\_Madhana\_Mohana\_Red](https://community.gatling.io/u/G_Madhana_Mohana_Red)\
**Post date:** [April 16, 2019, 5:08am UTC](https://community.gatling.io/t/polling-for-the-second-request-does-not-work/4907/5 "2019-04-16T05:08:52Z")

</div>

It seems polling is not working as specified in documentation, you can use below code for work around.

step 1: Create concurrent linked queue  
val queue = new ConcurrentLinkedQueue[String]  
step 2: Add number of times you would like to poll or status check or any variable.  
queue.add(session(“poll\_count”).as[String])  
Step 3: poll\_count = queue.poll()

.asLongAs(session =\> session(“poll\_count”).as[String] != “null”){  
exec(http(“Retrieve Execution Status”).get("/\_execute/"+"${execUID}"+"?wait\_for\_completion\_seconds="+TestConfig.duration)  
.check(status.is(200))  
.check(jsonPath("$.state").saveAs(“execState”))  
.check(bodyString.saveAs(“BODY”))  
.check(substring(“COMPLETED”).exists))  
}  
exec(session =\> {  
poll\_count = poll\_count-1  
session  
})
