Run Finalizer after Queueable
There are few benefits: reusable post-Queueable actions controls what happens when Queueable succeeds or fails easy way of logging results running summarizing jobs enqueue other jobs
Did you know that you can execute code after Queueable finishes?
It’s easier than you think! Let's add Finalizer to an example Queueable class:
public with sharing class QueueableExample implements Queueable {
public void execute(QueueableContext context) {
System.debug('An example of Queueable execution!');
}
}The first step is Finalizer implementation:
public with sharing class FinalizerExample implements Finalizer {
public void execute(FinalizerContext context) {
System.debug('Job done!');
}
}Next, attach Finalizer to Queueable execution:
public with sharing class QueueableExample implements Queueable {
public void execute(QueueableContext context) {
FinalizerExample myFinalizer = new FinalizerExample();
System.attachFinalizer(myFinalizer);
System.debug('An example of Queueable execution!');
}
}Okay, cool! But why would I want to do it?
There are few benefits: reusable post-Queueable actions controls what happens when Queueable succeeds or fails easy way of logging results running summarizing jobs enqueue other jobs
And a lot more! Check the links in the post to learn more.


