anusha(salesforce developer)

Tuesday 23 August 2016

how many batch jobs in queue in salesforce? (Force.com Spring '15 Release Apex Flex Queue)

Force.com Spring '15 Release
Apex Flex Queue



Submit up to 100 batch jobs simultaneously and actively manage the order of the queued jobs to control which batch jobs are processed first. This enhancement provides you more flexibility in managing your batch jobs.
Note: For all new organizations in Spring ’15, Apex Flex Queue is enabled by default. To enable Apex Flex Queue in an existing organization, activate the Apex Flex Queue critical update in Setup. This critical update doesn’t affect the behavior of existing Apex code that adds batch jobs to the queue for execution. The Holding status has been added for batch jobs, which might affect queries against AsyncApexJob. See “Critical Updates Overview” in the Salesforce Help for more details about critical updates.
Previously, you could submit only up to five batch jobs simultaneously. The Apex flex queue enables you to submit up to 100 batch jobs for execution. Any jobs that are submitted for execution are in holding status and are placed in the Apex flex queue. Up to 100 batch jobs can be in the holding status. When system resources become available, the system picks up jobs from the top of the Apex flex queue and moves them to the batch job queue. The system can process up to five queued or active jobs simultaneously. The status of these moved jobs changes from Holding to Queued. Queued jobs get executed when the system is ready to process new jobs.
Without administrator intervention, jobs are processed first-in first-out—in the order in which they’re submitted. Administrators can modify the order of jobs that are held in the Apex flex queue to control when they get processed by the system. For example, administrators can move a batch job up to the first position in the holding queue so that it’s the first job that gets processed when the system fetches the next held job from the flex queue. To monitor and reorder held batch jobs in the Salesforce user interface, from Setup click Jobs > Apex Flex Queue.

Submitting Jobs by Calling Database.executeBatch

When you submit batch jobs by calling Database.executeBatch, the system places your batch job in Holding status before processing the job.
The outcome of Database.executeBatch is as follows.
  • The batch job is placed in the Apex flex queue, and its status is set to Holding as long as the number of jobs in the flex queue hasn’t reached the maximum of 100.
  • If the Apex flex queue has the maximum number of jobs, Database.executeBatch throws a LimitException and doesn’t add the job to the queue.

When system resources become available, the system picks up the next job from the top of the flex queue for processing and changes its status to Queued.

New AsyncApexJob Status Field

The AsyncApexJob object, which represents a batch job, has a new Status field value of Holding. This new status indicates that the job is placed in the flex queue and is waiting to be processed when system resources become available.

Chain More Jobs with Queueable Apex

Queueable Apex was introduced in Winter ’15 and enables you to easily start and manage asynchronous processes. Previously, you could chain a queueable job to another job only once due to a limit. This limit has now been removed and you can chain an unlimited number of jobs in all Salesforce editions except Developer Edition. For Developer Edition organizations, the chained job limit has been raised to five chained jobs.
Chaining jobs is useful when you need to run a job after some other processing is done. To chain a job to another job, submit the second
job from the execute() method of your Queueable class. For example, if you have a second class that’s called SecondJob that
implements the Queueable interface, you can add this class to the queue in the execute() method as follows:
public class AsyncExecutionExample implements Queueable {
  public void execute(QueueableContext context) {
  // Your processing logic here
  // Chain this job to next job by submitting the next job
  System.enqueueJob(new SecondJob());
  }
  }
Only one child job can be started for each parent job in the chain, but the depth of the chain is unlimited for non-Developer Edition
organizations.

Processing Chained Jobs

When you chain one job to another job in the same transaction, a delay is added before the system processes the next child job. This delay starts with 1 second for the second submitted job and increases exponentially for subsequent jobs in the queue. For example, the third job has a delay of 2 seconds, the fourth job has a delay of 4 seconds, and so on, up to 64 seconds maximum delay. The delay is 2 to the nth power (2n), where n is the order of the next submitted child job starting from zero. After the eighth job, the delay stays constant at 64 seconds (26).
This delay applies only to queueable jobs that have been chained together, not to queueable jobs that were submitted from the same Queueable class. For example, if you submit three jobs by calling System.enqueueJob from the same Queueable class, these jobs are queued for execution and are processed independently without the additional delay.
String Methods Fixed for Escaping Additional Characters
When you activate this update, these Apex String methods will escape additional characters: escapeHtml3, escapeHtml4, and escapeEcmaScript.
Currently, these String methods don’t escape certain characters. When you activate this update, these methods will escape the following additional characters.
  • escapeHtml3: ' (single quote)
  • escapeHtml4: ' (single quote)
  • escapeEcmaScript: < (opening angle bracket) and > (closing angle bracket)
This update changes the behavior of the affected String class methods for all API versions.

Scheduled Apex Job Delay for Chained Jobs

This critical update adds a five-minute delay for new scheduled Apex jobs that are started from an asynchronous execution context, such as from batch Apex.
After you apply this update, the system activates the scheduled jobs that are started from an asynchronous execution context after the time delay has passed. Scheduled jobs whose start time is within the first five minutes after the job is created won’t run until the fire time that occurs after the delay, after which they continue to run at the specified interval.
This update minimizes the system-wide impact of Apex jobs that are chained together with scheduled Apex. Use the Queueable interface to chain Apex jobs, or if your process requires batch processing, call Database.executeBatch in the finish method of batch jobs.
The delay that this update adds doesn’t affect scheduled Apex jobs that are set up in the Salesforce user interface or started in a synchronous context.

No comments:

Post a Comment