How to deal with rate limiting in a Business Operation
I'm working with a REST API that will sometimes rate limit our requests by returning an HTTP 429 Too Many Requests status code. Is there a good way in a business operation to handle this by throttling our requests until we get a success response? My initial thoughts are:
- Reduce the pool size on the business operation to 1 so all requests are first in, first out.
- If the API returns a 429 response,
set %rate = $get(%rate,1)*2, then
hang %rate, then send the request to the back of the queue.
- If the API returns a success response,
I'm wondering if there's a better way to do this. Particularly if this is possible without limiting the business operation to run in a single process.