I tried the below example and it works fine:
QueueableExampleOne
public class QueueableExampleOne implements Queueable{
public void execute(QueueableContext context){
System.debug(System.LoggingLevel.ERROR,'From queueable example one');
System.enqueueJob(new QueuableExampleTwo());
}
}
QueuableExampleTwo
public class QueuableExampleTwo implements Queueable{
public void execute(QueueableContext ctxt){
System.debug(System.LoggingLevel.ERROR,'From QueueableContext example two');
}
}
I started the QueuebleExampleOne Job from developer console using the below code:
System.enqueueJob(new QueueableExampleOne());
And it worked fine and both the Queueable jobs execute methods executed successfully.
I am sure you might have read the below points from the documentation but posting here for the sake of complete answer.
- No limit is enforced on the depth of chained jobs, which means that you can chain one job to another job and repeat this process with
each new child job to link it to a new child job. For Developer
Edition and Trial organizations, the maximum stack depth for chained
jobs is 5, which means that you can chain jobs four times and the
maximum number of jobs in the chain is 5, including the initial
parent queueable job.
- When chaining jobs, you can add only one job from an executing job with System.enqueueJob, which means that only one child job can exist
for each parent queueable job. Starting multiple child jobs from the
same queueable job isn’t supported.
Id userUpdateJobId = System.enqueueJob(new UserProcess());
System.enqueueJob
from batch context. See the comment here - salesforce.stackexchange.com/questions/57367/…