Interview Question on Schedulable Apex

 

What is an apex Scheduler?

The Apex Scheduler lets you delay execution so that you can run Apex classes at a specified time. This is ideal for daily or weekly maintenance tasks using Batch Apex.

What is interface used for Schedulable Apex?

Schedulable interface

What are the methods used with a Schedulable interface?

 Only method this interface contains is the execute method.

What is the parameter of the execute method ?

The parameter of this method is a SchedulableContext object.

What happens after the class is scheduled?

After a class has been scheduled, a CronTrigger object is created that represents the scheduled job. It provides a getTriggerId method that returns the ID of a CronTrigger API object.

What are the arguments of the System.Schedule method?

The System.Schedule method takes three arguments:

Name for the job

CRON expression used to represent the time and date the job is scheduled to run

Name of the class.

How to Test Scheduled Apex?

To test Scheduled Apex you must ensure that the scheduled job is finished before testing against the results. To do this, use startTest and stopTest around the System.schedule method, to ensure processing finishes before continuing your test.

What is the governor limit of Scheduled Apex?

You can only have 100 scheduled Apex jobs at one time and there are a maximum number of scheduled Apex executions per a 24-hour period.

Can we make a callout from Scheduled Apex?

Synchronous Web service callouts are not supported from scheduled Apex.

How to monitor Scheduled Jobs?

After an Apex job has been scheduled, you can obtain more information about it by running a SOQL query on CronTrigger.

CronTrigger job = [SELECT Id, CronJobDetail.Id, CronJobDetail.Name, CronJobDetail.JobType FROM CronTrigger ORDER BY CreatedDate DESC LIMIT 1];

Did you enjoy this article?
Signup today and receive free updates straight in your inbox.
I agree to have my personal information transfered to MailChimp ( more information )
50% LikesVS
50% Dislikes