Lets understand how to execute, monitor and abort a batch
How to execute a Batch
Syntax:
<Class name> <object name> = new <class name> ();
Database.executebatch(object name, size of batch);
For example:
Batch class name: Calci
Open execute anonymous window in developer console and write:
Calci obj = new Calci();
Database.executebatch(obj,200);
Click execute!
How to Monitor the batch Job
Search Apex jobs in the setup and open it.
All the batch jobs will come in this page with completed/running/on hold.
Abort the Running Batch Job
To kill long running future Apex jobs from Workbench
- Go to Workbench.
- Select the Environment.
- Choose a lower API version to 32.0.
- Enter username and password.
- Go to Query | SOQL Query. Run the following query to find a queued status scheduled or future Apex job id to abort:
- SELECT ApexClassId,CompletedDate,CreatedById,CreatedDate,ExtendedStatus,Id,JobItemsProcessed,JobType,LastProcessed,LastProcessedOffset,MethodName,NumberOfErrors,ParentJobId,Status,TotalJobItems FROM AsyncApexJob where status = 'queued'
- Once you find the jobId to delete: Go to Utilities | Apex Execute.
- Replace text "JobID" in the following line of code with the Job Id you found in the query in step 5, then click Execute.
- System.abortJob('JobID');
- The scheduled Apex job should get deleted.
Let me know your thoughts in the comment section!!
No comments:
Post a Comment