Skip to content

Instantly share code, notes, and snippets.

@justin-lyon
Last active January 9, 2025 23:07
Show Gist options
  • Save justin-lyon/275e2526c004eb32b83599b882a40145 to your computer and use it in GitHub Desktop.
Save justin-lyon/275e2526c004eb32b83599b882a40145 to your computer and use it in GitHub Desktop.
Salesforce Apex Recursive Queueable for a service that is not bulkified
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);
}
}
}
@justin-lyon
Copy link
Author

@jamessimone you madlad. you're absolutely right

@jamessimone
Copy link

@jlyon87 <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment