I was testing Finalizer
interface with Queueable apex and I think it can also be used to overcome this error: System.LimitException: Too many queueable jobs added to the queue: 2
I created a class QueueTest
public with sharing class QueueTest implements Queueable, Finalizer{
private List<List<String>> strings;
public QueueTest(List<List<String>> strings){
this.strings = strings;
}
public void execute(FinalizerContext param1) {
System.enqueueJob(new QueueTest1());
}
public void execute(QueueableContext param1) {
QueueTest queueTest = new QueueTest(strings);
System.attachFinalizer(queueTest);
System.enqueueJob(new QueueTest1());
System.debug('Queueable executed');
}
}
and here I am firing two Queueable calls from same QueueTest
class. And I dont see any error.
But when I try to fire same back to back queueable from same execute
method I get the error Too many queueable jobs added to the queue: 2
.
Theoretically both are same, right? Or was finalizer created to overcome such limitations?