You need to sign in to do that
Don't have an account?

Scheduling multiple batchable apex classes in one place
I have two global classes, both implements Database.batchable
1. CleanDuplicateContacts
2. RestoreMergedContactInfo
#1 is kind of cleaning up my duplicates, so its merging records which in turn delete some contacts
#2 is parsing my recycle bin and find records that got deleted due to a merge and updating the winning record's custom field with the delete record's info.
now my question is
i have scheduled both of them in a single schedulable class like this
global class ScheduleRestoreMergedContactInfo implements Schedulable {
global void execute(SchedulableContext sc) {
System.Debug('Starting Cleanup');
CleanDuplicateContacts controller1 = new CleanDuplicateContacts();
Integer batchSize1 = 100;
database.executebatch(controller1, batchSize1);
System.Debug('Finished Cleanup');
System.Debug('Starting Gathering Info');
RestoreMergedContactInfo controller2 = new RestoreMergedContactInfo() ;
Integer batchSize2 = 1000;
database.executebatch(controller2 , batchSize2);
System.Debug('Finished Gathering Info');
}
}
will this work? will they run one after another or in parallel?
Let me know.
1. CleanDuplicateContacts
2. RestoreMergedContactInfo
#1 is kind of cleaning up my duplicates, so its merging records which in turn delete some contacts
#2 is parsing my recycle bin and find records that got deleted due to a merge and updating the winning record's custom field with the delete record's info.
now my question is
i have scheduled both of them in a single schedulable class like this
global class ScheduleRestoreMergedContactInfo implements Schedulable {
global void execute(SchedulableContext sc) {
System.Debug('Starting Cleanup');
CleanDuplicateContacts controller1 = new CleanDuplicateContacts();
Integer batchSize1 = 100;
database.executebatch(controller1, batchSize1);
System.Debug('Finished Cleanup');
System.Debug('Starting Gathering Info');
RestoreMergedContactInfo controller2 = new RestoreMergedContactInfo() ;
Integer batchSize2 = 1000;
database.executebatch(controller2 , batchSize2);
System.Debug('Finished Gathering Info');
}
}
will this work? will they run one after another or in parallel?
Let me know.


This should help you: https://blog.internetcreations.com/2011/09/executing-batch-apex-in-sequence/