Many REST APIs that people want to use from within Salesforce have asynchronous, long-running operation. For example
- An endpoint
POST /api/resourceto create a resource returning a handle Id to check
- Another endpoint
GET /api/resourceswith that Id to get the status/readiness of the creation
As many of such APIs don't send events that could be listened to in Salesforce, polling the second endpoint is all we can do in Salesforce.
The classical options to implement this are:
- Batch jobs that loop until a results is available
- Scheduled Apex to restart a check after a while (often not usable when the result is available after seconds or minutes)
- Queuable Apex
- A combination of all
Are there any solution patterns or even proven Open Source implementations on how to build such a polling in an elegant and scalable way?