Last active
January 9, 2025 23:07
-
-
Save justin-lyon/275e2526c004eb32b83599b882a40145 to your computer and use it in GitHub Desktop.
Salesforce Apex Recursive Queueable for a service that is not bulkified
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeServiceQueueable implements Queueable, Database.AllowsCallouts { | |
private List<Case> cases; | |
public SomeServiceQueueable (List<Case> newCases) { | |
this.cases = newCases; | |
} | |
public void execute (QueueableContext ctx) { | |
if (!this.cases.isEmpty()) { | |
Case toSend = this.cases.remove(0); | |
// TODO the stuff to send over the SomeService | |
// I didn't write the error handling for you! | |
SomeService.send(toSend); | |
} | |
if (!this.cases.isEmpty()) { | |
System.enqueueJob(this); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jamessimone you madlad. you're absolutely right