function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NicGallerNicGaller 

Queueable And Callouts

I have recently discovered the Queueable interface and thought this might be the perfect solution for my problem.  I need to process records in a trigger.  For each record I need to do between 4 and 8 callouts (dealing with a chatty API).  So I thought:

 * Get a list of the record
 * Enqueue the list
 * In the queueable, process the first record and re-enqueue the rest

This was great because I would only have one job executing at a time so I wouldn't overload the API, and I could even build a retry logic by putting a failed record back on the list.  BUT when I tried it with more than 1 record I started getting "maximum callout depth has been reached".  Reading about it it seems like it is just not possible to chain queueable with callouts... soo is that true?  It seems like a pretty big chunk of use cases for queueable that is neglected.  I'm puzzled too that it is not mentioned at all in the queueable documentation.  I can redo the code using batch Apex,  or maybe enqueue all my jobs from the trigger instead of chaining them, but I am surprised as I thought Queueable was here to solve this exact type of issue - hopefully I am just missing something.
NicGallerNicGaller
I found an idea for that one: https://success.salesforce.com/ideaView?id=08730000000Dl7VAAS.  So it looks like it is indeed a limitation, for now at least.  I wish it was better documented so I did not have to waste so much time wondering why it was not working.