This is a bit of an odd one. We are interacting with an external system that does not support concurrency due to a bug which they are struggling to fix. We perform a HTTP callout, the callout takes between 15 - 45 seconds to run.
During this time no other request to this web callout can occur or the system it is calling to will essentially crash. Because of how long this operation is, it must be an asynchronous job of some sort
NOTE: To clarify, if different transactions invoke this same callout within the same period it will cause the same issue, this problem is separate to Salesforce Transactions. A single Salesforce Transaction could require multiple callouts though
What we've thought of so far:
- Use scheduled batches (size of 1) and remove any transactional interactions with the API: This is an okay solution, it does allow us to run each call one at a time relatively safely, but we would like something that is closer to real time if possible
- Chained Jobs using Flex Queue + Queueable Interface: This sounds okay on a transactional level, but if two transactions occur at the same time / similar time it will create multiple chains
- Future jobs: This is what we're using right now, Future jobs will run whenever regardless of the status of other jobs and definitely allow the issue to occur
Is there another type of asynchronous processing interface we could not think of? Or a Salesforce mechanism to guarantee only one of an Interface will run at any given time