You need to sign in to do that
Don't have an account?

HTTP Callout work around
We are trying to integrate a callout to retrieve data and append to a record when inserted or updated. Given the limts of only 10 callouts per execution, we are trying to find a work around.
Initial thought was to have the trigger execute a batchable class to make the callouts, but it brings up the secondary issue of not having more than 5 batch jobs at a time. (
How would you guys handle? In the trigger, I could check if the list only contains 1-5 records and process normally, and if more than that then execute the batch class. But does this seem practical? What other limits might I be forgetting? I just want to make it will be scalable and won't break the first time we do a mass insert of a few thousand records.
Initial thought was to have the trigger execute a batchable class to make the callouts, but it brings up the secondary issue of not having more than 5 batch jobs at a time. (
How would you guys handle? In the trigger, I could check if the list only contains 1-5 records and process normally, and if more than that then execute the batch class. But does this seem practical? What other limits might I be forgetting? I just want to make it will be scalable and won't break the first time we do a mass insert of a few thousand records.
I would query for the queue of records that has to do the callout. If the queue is long enough (e.g. parameter in a custom setting, let's say 15), you launch the Batch from the trigger.
You have to be sure that only 1 trigger is executing at a given time, so you have to query in the start/( method and in the execute() method of the batch to know if, for mistake, there is another batch running.
If so you kill the current job.
Moreover you need a "garbage collector"; that is to say a batch that runs periodically (say 1 hour) in order not to have few records in the queue that are not executed: this is the same batch but scheduled once an hour (if this batch tries to execute while a "trigger one" is running, it "kills" itself).
Hope this helps
Enrico