How to set a time limit on the HttpClient.send in JavaScript in Apigee Edge

Hi Apigee Community!

Is there a way to setup a time limit of 50s to the httpClient.send and then when it reach the time limit, the process will exit the js policy and continue without error? (the goal of this is to exit the JS policy before the message processor timeout)


setTimeout and setInterval method are not supported by the JS in Apigee Edge, and waitforComplete is not good to use. Any suggestion on how to do that?

1 1 278
1 REPLY 1

I believe you can use the timeLimit attribute for this purpose. There is no documentation on what the valid range is, for the timeLimit. I suppose it must be positive, but I'm unsure if there is an upper limit. If you want 50 seconds you can try timeLimit="50000", along with continueOnError="true".

 

<Javascript name='JS-1' continueOnError="true" timeLimit='50000' >
  <ResourceURL>jsc://my-script-here.js</ResourceURL>
</Javascript>

 

If you don't set continueOnError="true", then when the JS step exceeds the time limit, the system will enter fault flow. It sounds like you don't want that; you want the processing to continue with "as much information as the JS step has provided." Do do that, use the continueOnError="true".