Sidebar

What is a best practice for timeout/delayed behavior while in the message pipeline

0 votes
355 views
asked May 17, 2018 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.

 

answered May 17, 2018 by michael-h-5027 (14,350 points)
selected May 17, 2018 by jason-m-6625
...