apex flex queue: batch apex liberated

27
Apex Liberation Carolina Ruiz Medina Principal Developer in Product Innovation Team at FinancialForce.com @CarolEnLaNube

Upload: carolenlanube

Post on 07-Jul-2015

597 views

Category:

Software


3 download

DESCRIPTION

The Apex Flex Queue brings an eagerly awaited update to batch Apex processing, allowing more jobs to be submitted at once and bringing greater control over queued jobs. Join us for an early look at this exciting new pilot feature.

TRANSCRIPT

Page 1: Apex Flex Queue: Batch Apex Liberated

Apex LiberationCarolina Ruiz Medina

Principal Developer in Product Innovation Team at FinancialForce.com

@CarolEnLaNube

Page 2: Apex Flex Queue: Batch Apex Liberated

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.

Page 3: Apex Flex Queue: Batch Apex Liberated

Place

Customer or

Partner logo in

white area of

slide, centered

Carolina Ruiz MedinaPrincipal Developer in Product Innovation

Team

Page 4: Apex Flex Queue: Batch Apex Liberated

• 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

Page 5: Apex Flex Queue: Batch Apex Liberated

Before

Asynchronous to process large amount of data

• @Future

• Batch Jobs

• Schedule Jobs

• Which

options do

we have?What is it?

Page 6: Apex Flex Queue: Batch Apex Liberated

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

Page 7: Apex Flex Queue: Batch Apex Liberated

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

}

}

Page 8: Apex Flex Queue: Batch Apex Liberated

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

Page 9: Apex Flex Queue: Batch Apex Liberated

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){

}

}

Page 10: Apex Flex Queue: Batch Apex Liberated
Page 11: Apex Flex Queue: Batch Apex Liberated
Page 12: Apex Flex Queue: Batch Apex Liberated

and Now..

@Future BatchFlex Queue

Page 13: Apex Flex Queue: Batch Apex Liberated

and Now..

Asynchronous

• @Future

• Batch Jobs : With FlexQue

• Schedule Jobs

• Queueable Interface

Page 14: Apex Flex Queue: Batch Apex Liberated
Page 15: Apex Flex Queue: Batch Apex Liberated

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

Page 16: Apex Flex Queue: Batch Apex Liberated

More than 5 Apex Jobs

More than 5 Apex Jobs in the Apex Jobs Table

Flex Queue

Now

Show me!

Page 17: Apex Flex Queue: Batch Apex Liberated

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!

Page 18: Apex Flex Queue: Batch Apex Liberated

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?!

Page 19: Apex Flex Queue: Batch Apex Liberated

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!

Page 20: Apex Flex Queue: Batch Apex Liberated

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?

Page 21: Apex Flex Queue: Batch Apex Liberated

Use to

introduce a

demo, video,

Q&A, etc. Demo Aborting Jobs

Page 22: Apex Flex Queue: Batch Apex Liberated

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

Page 23: Apex Flex Queue: Batch Apex Liberated

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];

Page 24: Apex Flex Queue: Batch Apex Liberated

Use to

introduce a

demo, video,

Q&A, etc. Demo Queueauble interface

Page 26: Apex Flex Queue: Batch Apex Liberated

Q&A

as I always say… Easy questions please ☺

@CarolEnLaNube

Page 27: Apex Flex Queue: Batch Apex Liberated