apex flex queue: batch apex liberated
Post on 07-Jul-2015
584 Views
Preview:
DESCRIPTION
TRANSCRIPT
Apex LiberationCarolina Ruiz Medina
Principal Developer in Product Innovation Team at FinancialForce.com
@CarolEnLaNube
Safe Harbor
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of
the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking
statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service
availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future
operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of
our services.
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service,
new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or
delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and
acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and
manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization
and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our
annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and
others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site.
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be
delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
Place
Customer or
Partner logo in
white area of
slide, centered
Carolina Ruiz MedinaPrincipal Developer in Product Innovation
Team
• San Francisco Headquarters
• Harrogate, UK
• Granada, Spain
• Toronto, Canada
• Manchester, US
• Opening Sydney, AUS in Sept, 2014
• 350+ Employees
• 400+ by 12/31/2014
• Customers in 31 countries
• 80% Y-o-Y revenue growth
• Advent commitment of $50 million
About FinancialForce.com
Before
Asynchronous to process large amount of data
• @Future
• Batch Jobs
• Schedule Jobs
• Which
options do
we have?What is it?
Before
• The methods execute when
Salesforce has available
resources
• @future only
returns void type
@Future • Parameters must be
primitive data types
We can’t monitor
the future jobs
• The method does not
necessarily execute in
the same order is
called
• Future methods must
be static methods
• No job ID for @future jobs
Before
public with sharing class FutureClass {
@future
static void myMethod(String a, Integer i) {
System.debug('Method called with: ' + a + ' and ' + i+'... and I loved the sunny days :)');
// Perform long-running code
}
}
Before:
Batch Jobs
Before
• Database.executeBatch
returns Id
• We can monitor the batch jobs
• We can’t order
batch jobs
• Only 5 active jobs are
allow in the queue at the
same time ( //show error )
• Interfaces that we can
override in order to
process data
• Possibility to use iterator
– process different objet
type in the same batch
• Recursive calls
Before: Beforepublic class UpdateAccountFields implements Database.Batchable<sObject>{
public final String Query; public final String Entity;
public final String Field; public final String Value;
public UpdateAccountFields(String q, String e, String f, String v){
Query=q; Entity=e; Field=f;Value=v;
}
public Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
public void execute(Database.BatchableContext BC,
List<sObject> scope){
for(Sobject s : scope){s.put(Field,Value);
} update scope;
}
public void finish(Database.BatchableContext BC){
}
}
and Now..
@Future BatchFlex Queue
and Now..
Asynchronous
• @Future
• Batch Jobs : With FlexQue
• Schedule Jobs
• Queueable Interface
More than 5 Apex Jobs
More than 5 Apex Jobs in the Apex Jobs Table
5 Apex Jobs Processing + 95 Apex Jobs Holding
New UI to monitor and manage the Apex Jobs in Holding Status
Reorder the holding Apex Jobs
Flex Queue
Now
More than 5 Apex Jobs
More than 5 Apex Jobs in the Apex Jobs Table
Flex Queue
Now
Show me!
More than 5 Apex Jobs
More than 5 Apex Jobs in the Apex Jobs Table
5 Apex Jobs Processing + 95 Apex Jobs Holding
Flex Queue
Now
I don’t believe you, show that!
More than 5 Apex Jobs
More than 5 Apex Jobs in the Apex Jobs Table
5 Apex Jobs Processing + 95 Apex Jobs Holding
New UI to monitor and manage the Apex Jobs in Holding Status
Flex Queue
Now
Where is it? How does it work?!
More than 5 Apex Jobs
More than 5 Apex Jobs in the Apex Jobs Table
5 Apex Jobs Processing + 95 Apex Jobs Holding
New UI to monitor and manage the Apex Jobs in Holding Status
Reorder the holding Apex Jobs
Flex Queue
Now
Lets reorder then!
Flex Queue
• Schedule Jobs: do they work in the same way?
Maybe you are thinking now…
Yes, everything continues exactly the same. The benefit is now we can schedule and run jobs that call apex jobs having the benefit of Flex Queue that allow us to set the Batch in Holding status
Then
• Can I reorder using any apex Method?
• Can I abort the Holding Jobs by UI or using System.Abort?
Use to
introduce a
demo, video,
Q&A, etc. Demo Aborting Jobs
Taking Care!!
• Only re order when necessary
• If there are batch jobs that are dependent to others!
• If there are chaining batch jobs
With a big power became a big responsibility
Extra
public class AsyncExecutionExample implements Queueable {
public void execute(QueueableContext context) {
Account a = new Account(Name='Acme',Phone='(415) 555-1212');
insert a;
}
}
Submit and Monitor Jobs for Asynchronous Execution with the Queueable Interface
ID jobID = System.enqueueJob(new AsyncExecutionExample());
AsyncApexJob jobInfo = [SELECT Status,NumberOfErrors FROM AsyncApexJob WHERE
Id=:jobID];
Use to
introduce a
demo, video,
Q&A, etc. Demo Queueauble interface
Links
• Josh Kaplan blog
• Apex Developer guide
• Winter ‘15 release notes
Q&A
as I always say… Easy questions please ☺
@CarolEnLaNube
top related