First Batch:
global class BatchCalledThroughQueueable implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallouts {
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc, List<Lead> records){
}
global void finish(Database.BatchableContext bc){
}
}
Second Queueable Class:
public class ExecuteBatchQueueableJob implements Queueable {
public void execute(QueueableContext context) {
try{
BatchCalledThroughQueueable b = new BatchCalledThroughQueueable();
Database.executeBatch(b, 200);
}catch(Exception e){
System.debug('@@@ Error Message : '+e.getMessage());
}
}
}
Third Batch:
global class BatchUpdate implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallouts {
global Database.QueryLocator start(Database.BatchableContext bc) {
Note: Calling Queueable job for calling the next batchfor chaining.
System.enqueueJob(new ExecuteBatchQueueableJob());
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc, List<Contact> records){
}
global void finish(Database.BatchableContext bc){
}
}
No comments:
Post a Comment