SimpleQueueable.cls:
public with sharing class SimpleQueueable implements System.Queueable{
public void execute(System.QueueableContext ctxt){
//query the record inserted in calling transaction
//make some changes on the record and update the record.
}
}
Sample code of calling transaction:
SimpleQueueable job = new SimpleQueueable();
System.enqueueJob(job);
Long start = System.now().getTime();
while(System.now().getTime() - start < 6000 ){
}
// Decimal x = 6/0; If I uncomment this line queueable is not running.
Behavior of Queueable job :
- Only run if calling transaction completes successfully.
- Only run after the completion of calling transaction and should not run in parallel with calling transaction.
- Query the record that is inserted in the calling transaction and do some updates and update the record.
About calling transaction:
Calling transaction starts with custom code and ends with managed package code. So, I don't have a way to know when the calling transaction ends.
What I have noticed:
- If the calling transaction is failing then queueuable is not executed.
- Queueable job is executed after the calling transaction is completed.
Can someone confirm this or my findings wrong?