1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
541 views
by jason-m-6625 (170 points)

We have a scenario that we need to go into a http service retry loop within one of our channels (via a recursively called published function) that either exits when a timeout bank expires or we get a satisfactory result from the http service. This is working great so far, but there is no throttling of the loop, so the http service we are calling is getting hammered with requests. To ease the number of requests we are making, I would like to delay each recursive loop by a given interval. Does qvera support suspending the current thread or are there other best practices for this scenario?

Pseudo example:
function foo() {
  if (timebank > 0) {
    var result = callWebService();

    if (result.isGood) {
      //run exit routine by saving state to messagCache
    } else {
      //recursively call foo
      Thread.sleep(x * 100); // Is this safe?
      foo();
    }
  }
}

 

1 Answer

+2 votes
 
Best answer

Sounds like you are looking for the qie.pause() function.

 

by michael-h-5027 (14.8k points)
selected by jason-m-6625
...