Beruflich Dokumente
Kultur Dokumente
Dave Helgerson
davehelgerson.com
@davehelgerson
QueryLocator Example
List Example
Iterable Example
Database.Stateful
State is maintained between transactions
Instance member variables retain their values
Static member variables are reset
Scheduable
Combine the scheduling class with the Batch
Apex class
global void execute(SchedulableContext sc){
(cont.)
Database.executeBatch
Submits a job to the queue
Parameters:
Instance of the class
Scope (optional)
Example:
Database.executeBatch(new ExampleBatch(),
100);
(cont.)
System.scheduleBatch
Creates a scheduled job
Parameters:
Instance of the class
Job name
Time interval, in minutes, after which the job
should start executing
Scope (optional)
Example:
System.scheduleBatch(new ExampleBatch(),
'Test', 5, 100);
(cont.)
Job Id is returned
Track progress by the job Id
Scheduling in Apex
system.schedule()
Name
Cron expression
Instance of Schedulable class
Example:
system.schedule('My Scheduled Job',
'0 15 * * * ?', new ExampleSchedulable());
Considerations Summary
QueryLocator - maximum of 50m records
Custom Iterators - maximum of 50k
records
Governor limits apply to each invocation
of the execute method()
@future methods cannot be called
Timing is determined by Salesforce
5 concurrent jobs can process at once
100 jobs can be in the queue
Demo
Submitting
Scheduling
Monitoring
Questions?
davehelgerson.com
@davehelgerson