Exception Handler - Cases
Last updated
Last updated
"Exception Handlers" can be used to solve many common situations. Here we list some of them and their possible solutions
Many APIs implement rate-limit mechanisms that specify a maximum number of requests that can be executed in a given time period. Through an Exception Handler we can adjust the operation of a flow to stay within the defined rate.
The flow below accesses an API hundreds of times that is configured to accept a maximum of 10 requests per minute.
We set up an "Exception Handlers" for this flow with the following characteristics:
Name: Too Many Requests
Scope: Flow
Exception Rule: 429 Too Many Requests
Name: 429 Error Code
Retries: 2. At first only one retry would be enough, but we set two as safety margin.
Seconds: 60. The API in question releases tokens every minute, so we wait a full minute until we restart the requests.
Notification to syslog and local. It's important to be able to audit and track when we're exceeding the usage rates of an API
Message: Too many requests - RETRY
Default Action
Notification to syslog and local.
Message: Too many requests - FATAL. In this case we can identify that despite the exception handling the error persisted.
Final Action: Stop. This action will be taken only if the strategy of waiting for new tokens fails, which indicates that there is some unexpected situation that caused this error.
This strategy guarantees correct API usage if only one execution of this stream occurs at the same time. To force this situation you can disable concurrent flow executions as illustrated below.