SlideShare a Scribd company logo
Asynchronous Apex
Paris June 25, 2015
Samuel De Rycke
Salesforce MVP
ABSI
@SamuelDeRycke
Samuel Moyson
Developer
ABSI
@SamuelMoyson
Speakers
#DevZone #SalesforceWorldTour #AsyncApex
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 intellectual property and other
litigation, risks associated with 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-Q for the
most recent fiscal quarter ended July 31, 2012. This 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.
Follow Developer Force for the Latest News
@SalesforceDevs – #SalesforceDevs
Developer Force – Force.com Community
+Developer Force – Force.com Community
Developer Force
Developer Force Group
Synchronous vs Asynchronous
• Synchronous
• Asynchronous
Process 1
Process 2
Waiting for response
Process 1
Process 2
Continues working
Get response
• Synchronous
•Immediate and fast actions
•Enforce single, serial, transactions
•Normal governor limits
• Asynchronous
•Actions that should not block the rest of the process
•Processes where duration is of lesser concern
•Higher governor limits
Synchronous vs Asynchronous
Types of Asynchronous Apex
• Batch Apex
• Future Methods
• Queueable
• Scheduled
• Continuation
Batch Apex
Use when you want to:
• Process a big “batch” of records in smaller “batches” of records
• Each smaller batch is handled in a discrete transaction
• Monitor queue of batch jobs
• Batchable context with information about batch
Batch Apex
Start
Execute
Finish
global Database.QueryLocator start(Database.BatchableContext BC) {
//Query for data
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope) {
//Do some actions with data
//DML Statement
}
global void finish(Database.BatchableContext BC) {
//Give some feedback about statistics of batch
//Do post batch actions
}
Batch Apex
Process up to 50 million records
Monitor batch progress in the Setup User Interface
Admins can reorder batch priority with Apex Flex Queue
Maximum 5 concurrent batches processed (status Queued)
Not always easy to debug
Future Methods
Use when you want to:
• Execute methods that should not delay or respond to the
current Apex transaction
• Isolate transaction contexts and DML contexts
• Make asynchronous call outs to Web services
Pilot: Future methods with Higher Limits
• Set specific governor limits for a specific method x2 or x3
Future Methods
Executepublic class MyClass
{
public void myNormalMethod{
List<ID> recordIds;
//Synchronous logic here
myFutureMethod(recordIds);
// More synchronous logic
}
@future
public static void myFutureMethod(List<ID> recordIds)
{
// Get those records based on the IDs
// Process records
}
}
@future
Future Methods
Executed near instantly
Bypass mixed DML limitations
Pilot: increase limits for specific methods
Maximum 50 future methods per Apex invocation
Only accepts (collections of) primitive data types
Future methods can not invoke other future methods
Can not be invoked from Visualforce Constructors, Get & Set
Queueable Apex
Use when you want to:
• Start long-running operations and monitor them within the
current process or the user interface
• Pass complex types
• Chain asynchronous jobs
Queueable Apex
implements
Queueable
ID jobID = System.enqueueJob(new MyQueueableJob ());
public class MyQueueableJob implements Queueable {
//Other logic
public void execute(QueueableContext context) {
//Asynchronous logic here
//Optionally: enqueue another job
}
}
Queueable Apex
Executed near instantly
Unlimited depth of chained jobs (except for Dev & Trial orgs)
Use sObject and Apex objects as parameters
Maximum 50 jobs queued in a single apex transaction
When chaining jobs only 1 ‘child job’ is supported
Jobs can not be chained in test context.
Chained jobs do not support callouts (Winter ‘16 ?)
Schedulable Apex
Use when you want to:
• Schedule Apex classes
• Specify schedule with User Interface or Apex
Schedulable Apex
// Schedulable class
global class MySchedulable implements Schedulable {
global void execute(SchedulableContext sc) {
// Execute apex
}
}
// Schedule from Apex:
MySchedulable schApex = new MySchedulable ();
String sch = '0 15 10 * * ?';
String jobID = System.schedule('MySchedulable', sch, schApex);
implements
Schedulable
Schedulable Apex
Schedule from UI
Schedulable Apex
Execute Apex on scheduled intervals
Admins can manage the schedule from the Setup UI
Maximum 100 scheduled jobs at the same time
Using the Setup User Interface the minimum interval is 1 hour
Synchronous web service callouts are not supported
Continuation
Use when you want to:
–Make callouts from Visualforce pages
–Special one: synchronous asynchronous
Twitter demo
https://github.com/SamuelMoy/TwitterContinuationDemo
Continuation
Visualforce Continuation Webservice
startRequest
processResponse
Class
● Objects
● Methods
Continuation
// Visualforce page
<apex:page showHeader="true" sidebar="true" controller="TwitterController">
<apex:form >
<!-- Invokes the action method when the user clicks this button. -->
<apex:commandButton action="{!startRequest}" value="Start"
reRender="result"/>
</apex:form>
<!-- This output text component displays the callout response body. -->
<apex:outputText id="result" value="{!status} " />
</apex:page>
Visualforce
Continuation
// Action method
public Object startRequest() {
// Create continuation with a timeout
Continuation con = new Continuation(40);
// Set callback method
con.continuationMethod='processResponse';
HttpRequest req = new HttpRequest();
// Add callout request to continuation
this.requestLabel = con.addHttpRequest(req);
// Return the continuation
return con;
}
startRequest
Continuation
// Callback method
public Object processResponse() {
// Get the response by using the unique label
HttpResponse response = Continuation.getResponse(this.requestLabel);
// Set the result variable that is displayed on the Visualforce page
this.result = response.getBody();
// Return null to re-render the original Visualforce page
return null;
}
processResponse
Continuation
Integrate Visualforce with back-end systems
No long-running concurrent request limit for call outs
that last longer than 5 seconds
Visualforce page suspended until action completed
(= Synchronous)
Maximum 3 asynchronous callouts in one single Continuation
Maximum timeout continuation is 120 seconds
Testing Asynchronous Apex
• Invoke asynchronous Apex between the Test.startTest() and
Test.stopTest() methods.
• The Test.stopTest() method will execute all asynchronous and
scheduled Apex synchronously.
• Assert :-)
Recap
Batch Future Schedulable Queueable Continuation
High volume
of records
Near instantly
Primitive
parameters
Schedule jobs Chain jobs
Complex
parameters
Callouts in
Visualforce
Samuel De Rycke
Salesforce MVP
ABSI
@SamuelDeRycke
Samuel Moyson
Developer
ABSI
@SamuelMoyson
Q & A
developer.salesforce.com/trailhead
La communauté des développeurs Salesforce en France
Rejoignez la communauté de développeurs en France et venez partager votre expérience
sur la plateforme Salesforce1
bit.ly/dugParis
bit.ly/dugStQuentin
bit.ly/dugSuisse
bit.ly/dugBelgique
Thank you
Ad

More Related Content

What's hot (20)

Introduction to Apex Triggers
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex Triggers
Salesforce Developers
 
Understanding Presto - Presto meetup @ Tokyo #1
Understanding Presto - Presto meetup @ Tokyo #1Understanding Presto - Presto meetup @ Tokyo #1
Understanding Presto - Presto meetup @ Tokyo #1
Sadayuki Furuhashi
 
Deep Dive into Apex Triggers
Deep Dive into Apex TriggersDeep Dive into Apex Triggers
Deep Dive into Apex Triggers
Salesforce Developers
 
Oracle Fusion Architecture
Oracle Fusion ArchitectureOracle Fusion Architecture
Oracle Fusion Architecture
Vinay Kumar
 
Exploring the Salesforce REST API
Exploring the Salesforce REST APIExploring the Salesforce REST API
Exploring the Salesforce REST API
Salesforce Developers
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
Mauro Pagano
 
ORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate Overview
Brett Meyer
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
John Beresniewicz
 
Oracle forms personalization
Oracle forms personalizationOracle forms personalization
Oracle forms personalization
Kaushik Kumar Kuberanathan
 
SOQL in salesforce || Salesforce Object Query Language || Salesforce
SOQL in salesforce || Salesforce Object Query Language || SalesforceSOQL in salesforce || Salesforce Object Query Language || Salesforce
SOQL in salesforce || Salesforce Object Query Language || Salesforce
Amit Singh
 
Apex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard ProblemsApex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard Problems
Salesforce Developers
 
Reactive programming intro
Reactive programming introReactive programming intro
Reactive programming intro
Ahmed Ehab AbdulAziz
 
Expose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridExpose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug Madrid
Vinay Kumar
 
Oracle ZDM KamaleshRamasamy Sangam2020
Oracle ZDM KamaleshRamasamy Sangam2020Oracle ZDM KamaleshRamasamy Sangam2020
Oracle ZDM KamaleshRamasamy Sangam2020
Kamalesh Ramasamy
 
Oracle E-Business Suite 12.2 - The Upgrade to End All Upgrades
Oracle E-Business Suite 12.2 - The Upgrade to End All UpgradesOracle E-Business Suite 12.2 - The Upgrade to End All Upgrades
Oracle E-Business Suite 12.2 - The Upgrade to End All Upgrades
Shiri Amit
 
Oracle Client Failover - Under The Hood
Oracle Client Failover - Under The HoodOracle Client Failover - Under The Hood
Oracle Client Failover - Under The Hood
Ludovico Caldara
 
Computer Science:Sql Set Operation
Computer Science:Sql Set OperationComputer Science:Sql Set Operation
Computer Science:Sql Set Operation
St Mary's College,Thrissur,Kerala
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Aaron Shilo
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
Edureka!
 
Oracle Retail Merchandise System
Oracle Retail Merchandise SystemOracle Retail Merchandise System
Oracle Retail Merchandise System
Adeel Siddiqui
 
Understanding Presto - Presto meetup @ Tokyo #1
Understanding Presto - Presto meetup @ Tokyo #1Understanding Presto - Presto meetup @ Tokyo #1
Understanding Presto - Presto meetup @ Tokyo #1
Sadayuki Furuhashi
 
Oracle Fusion Architecture
Oracle Fusion ArchitectureOracle Fusion Architecture
Oracle Fusion Architecture
Vinay Kumar
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
Mauro Pagano
 
ORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate Overview
Brett Meyer
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
John Beresniewicz
 
SOQL in salesforce || Salesforce Object Query Language || Salesforce
SOQL in salesforce || Salesforce Object Query Language || SalesforceSOQL in salesforce || Salesforce Object Query Language || Salesforce
SOQL in salesforce || Salesforce Object Query Language || Salesforce
Amit Singh
 
Apex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard ProblemsApex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard Problems
Salesforce Developers
 
Expose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridExpose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug Madrid
Vinay Kumar
 
Oracle ZDM KamaleshRamasamy Sangam2020
Oracle ZDM KamaleshRamasamy Sangam2020Oracle ZDM KamaleshRamasamy Sangam2020
Oracle ZDM KamaleshRamasamy Sangam2020
Kamalesh Ramasamy
 
Oracle E-Business Suite 12.2 - The Upgrade to End All Upgrades
Oracle E-Business Suite 12.2 - The Upgrade to End All UpgradesOracle E-Business Suite 12.2 - The Upgrade to End All Upgrades
Oracle E-Business Suite 12.2 - The Upgrade to End All Upgrades
Shiri Amit
 
Oracle Client Failover - Under The Hood
Oracle Client Failover - Under The HoodOracle Client Failover - Under The Hood
Oracle Client Failover - Under The Hood
Ludovico Caldara
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Aaron Shilo
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
Edureka!
 
Oracle Retail Merchandise System
Oracle Retail Merchandise SystemOracle Retail Merchandise System
Oracle Retail Merchandise System
Adeel Siddiqui
 

Viewers also liked (20)

Salesforce1 API Overview
Salesforce1 API OverviewSalesforce1 API Overview
Salesforce1 API Overview
Samuel De Rycke
 
Integration with the Salesforce App Cloud - Amsterdam 2016
Integration with the Salesforce App Cloud - Amsterdam 2016Integration with the Salesforce App Cloud - Amsterdam 2016
Integration with the Salesforce App Cloud - Amsterdam 2016
Samuel De Rycke
 
Design Patterns for Asynchronous Apex
Design Patterns for Asynchronous ApexDesign Patterns for Asynchronous Apex
Design Patterns for Asynchronous Apex
Salesforce Developers
 
Spring '16 release belgium salesforce user group samuel de rycke
Spring '16 release belgium salesforce user group samuel de ryckeSpring '16 release belgium salesforce user group samuel de rycke
Spring '16 release belgium salesforce user group samuel de rycke
Samuel De Rycke
 
Getting Certified - proven tips for success (French Touch Dreamin)
Getting Certified - proven tips for success (French Touch Dreamin)Getting Certified - proven tips for success (French Touch Dreamin)
Getting Certified - proven tips for success (French Touch Dreamin)
Samuel De Rycke
 
Salesforce APIs
Salesforce APIsSalesforce APIs
Salesforce APIs
Samuel De Rycke
 
A Taste of Lightning in Action
A Taste of Lightning in ActionA Taste of Lightning in Action
A Taste of Lightning in Action
Steven Hugo
 
Custom Metadata Data Types
Custom Metadata Data TypesCustom Metadata Data Types
Custom Metadata Data Types
Samuel Moyson
 
Salesforce Flexible Pages
Salesforce Flexible PagesSalesforce Flexible Pages
Salesforce Flexible Pages
Samuel De Rycke
 
Lightning Chess at the Sri Sanka Salesforce Developer Group
Lightning Chess at the Sri Sanka  Salesforce Developer GroupLightning Chess at the Sri Sanka  Salesforce Developer Group
Lightning Chess at the Sri Sanka Salesforce Developer Group
Samuel De Rycke
 
Advanced Apex Development - Asynchronous Processes
Advanced Apex Development - Asynchronous ProcessesAdvanced Apex Development - Asynchronous Processes
Advanced Apex Development - Asynchronous Processes
Salesforce Developers
 
Salesforce World Tour Amsterdam: Guide your users through a process using path
Salesforce World Tour Amsterdam:  Guide your users through a process using pathSalesforce World Tour Amsterdam:  Guide your users through a process using path
Salesforce World Tour Amsterdam: Guide your users through a process using path
Lieven Juwet
 
ABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - PresentationABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - Presentation
Julie Minner
 
Lightning chess
Lightning chessLightning chess
Lightning chess
Lieven Juwet
 
Absi summmer BBQ Presentation on Going Digital
Absi summmer BBQ Presentation on Going DigitalAbsi summmer BBQ Presentation on Going Digital
Absi summmer BBQ Presentation on Going Digital
ABSI_NV
 
ABSI Summer Event 2015
ABSI Summer Event 2015ABSI Summer Event 2015
ABSI Summer Event 2015
ABSI_NV
 
Enterprise Integration - Solution Patterns From the Field
Enterprise Integration - Solution Patterns From the FieldEnterprise Integration - Solution Patterns From the Field
Enterprise Integration - Solution Patterns From the Field
Salesforce Developers
 
Salesforce Apex Ten Commandments
Salesforce Apex Ten CommandmentsSalesforce Apex Ten Commandments
Salesforce Apex Ten Commandments
NetStronghold
 
Apex Flex Queue: Batch Apex Liberated
Apex Flex Queue: Batch Apex LiberatedApex Flex Queue: Batch Apex Liberated
Apex Flex Queue: Batch Apex Liberated
CarolEnLaNube
 
Build Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable ApexBuild Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable Apex
Salesforce Developers
 
Salesforce1 API Overview
Salesforce1 API OverviewSalesforce1 API Overview
Salesforce1 API Overview
Samuel De Rycke
 
Integration with the Salesforce App Cloud - Amsterdam 2016
Integration with the Salesforce App Cloud - Amsterdam 2016Integration with the Salesforce App Cloud - Amsterdam 2016
Integration with the Salesforce App Cloud - Amsterdam 2016
Samuel De Rycke
 
Design Patterns for Asynchronous Apex
Design Patterns for Asynchronous ApexDesign Patterns for Asynchronous Apex
Design Patterns for Asynchronous Apex
Salesforce Developers
 
Spring '16 release belgium salesforce user group samuel de rycke
Spring '16 release belgium salesforce user group samuel de ryckeSpring '16 release belgium salesforce user group samuel de rycke
Spring '16 release belgium salesforce user group samuel de rycke
Samuel De Rycke
 
Getting Certified - proven tips for success (French Touch Dreamin)
Getting Certified - proven tips for success (French Touch Dreamin)Getting Certified - proven tips for success (French Touch Dreamin)
Getting Certified - proven tips for success (French Touch Dreamin)
Samuel De Rycke
 
A Taste of Lightning in Action
A Taste of Lightning in ActionA Taste of Lightning in Action
A Taste of Lightning in Action
Steven Hugo
 
Custom Metadata Data Types
Custom Metadata Data TypesCustom Metadata Data Types
Custom Metadata Data Types
Samuel Moyson
 
Salesforce Flexible Pages
Salesforce Flexible PagesSalesforce Flexible Pages
Salesforce Flexible Pages
Samuel De Rycke
 
Lightning Chess at the Sri Sanka Salesforce Developer Group
Lightning Chess at the Sri Sanka  Salesforce Developer GroupLightning Chess at the Sri Sanka  Salesforce Developer Group
Lightning Chess at the Sri Sanka Salesforce Developer Group
Samuel De Rycke
 
Advanced Apex Development - Asynchronous Processes
Advanced Apex Development - Asynchronous ProcessesAdvanced Apex Development - Asynchronous Processes
Advanced Apex Development - Asynchronous Processes
Salesforce Developers
 
Salesforce World Tour Amsterdam: Guide your users through a process using path
Salesforce World Tour Amsterdam:  Guide your users through a process using pathSalesforce World Tour Amsterdam:  Guide your users through a process using path
Salesforce World Tour Amsterdam: Guide your users through a process using path
Lieven Juwet
 
ABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - PresentationABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - Presentation
Julie Minner
 
Absi summmer BBQ Presentation on Going Digital
Absi summmer BBQ Presentation on Going DigitalAbsi summmer BBQ Presentation on Going Digital
Absi summmer BBQ Presentation on Going Digital
ABSI_NV
 
ABSI Summer Event 2015
ABSI Summer Event 2015ABSI Summer Event 2015
ABSI Summer Event 2015
ABSI_NV
 
Enterprise Integration - Solution Patterns From the Field
Enterprise Integration - Solution Patterns From the FieldEnterprise Integration - Solution Patterns From the Field
Enterprise Integration - Solution Patterns From the Field
Salesforce Developers
 
Salesforce Apex Ten Commandments
Salesforce Apex Ten CommandmentsSalesforce Apex Ten Commandments
Salesforce Apex Ten Commandments
NetStronghold
 
Apex Flex Queue: Batch Apex Liberated
Apex Flex Queue: Batch Apex LiberatedApex Flex Queue: Batch Apex Liberated
Apex Flex Queue: Batch Apex Liberated
CarolEnLaNube
 
Build Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable ApexBuild Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable Apex
Salesforce Developers
 
Ad

Similar to Asynchronous Apex Salesforce World Tour Paris 2015 (20)

Spring '14 Release Developer Preview Webinar
Spring '14 Release Developer Preview WebinarSpring '14 Release Developer Preview Webinar
Spring '14 Release Developer Preview Webinar
Salesforce Developers
 
Intro to Apex Programmers
Intro to Apex ProgrammersIntro to Apex Programmers
Intro to Apex Programmers
Salesforce Developers
 
Salesforce1 Platform for programmers
Salesforce1 Platform for programmersSalesforce1 Platform for programmers
Salesforce1 Platform for programmers
Salesforce Developers
 
Coding Apps in the Cloud with Force.com - Part 2
Coding Apps in the Cloud with Force.com - Part 2Coding Apps in the Cloud with Force.com - Part 2
Coding Apps in the Cloud with Force.com - Part 2
Salesforce Developers
 
Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex! Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex!
Salesforce Developers
 
ELEVATE Paris
ELEVATE ParisELEVATE Paris
ELEVATE Paris
Peter Chittum
 
Spring '16 Release Preview Webinar
Spring '16 Release Preview Webinar Spring '16 Release Preview Webinar
Spring '16 Release Preview Webinar
Salesforce Developers
 
Advanced Apex Webinar
Advanced Apex WebinarAdvanced Apex Webinar
Advanced Apex Webinar
pbattisson
 
Design Patterns Every ISV Needs to Know (October 15, 2014)
Design Patterns Every ISV Needs to Know (October 15, 2014)Design Patterns Every ISV Needs to Know (October 15, 2014)
Design Patterns Every ISV Needs to Know (October 15, 2014)
Salesforce Partners
 
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStoreDeveloping Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Tom Gersic
 
Quickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics CloudQuickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics Cloud
Salesforce Developers
 
Force.com Friday : Intro to Apex
Force.com Friday : Intro to Apex Force.com Friday : Intro to Apex
Force.com Friday : Intro to Apex
Salesforce Developers
 
Elevate workshop programmatic_2014
Elevate workshop programmatic_2014Elevate workshop programmatic_2014
Elevate workshop programmatic_2014
David Scruggs
 
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDKLook Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
Salesforce Developers
 
Hands-on Workshop: Intermediate Development with Heroku and Force.com
Hands-on Workshop: Intermediate Development with Heroku and Force.comHands-on Workshop: Intermediate Development with Heroku and Force.com
Hands-on Workshop: Intermediate Development with Heroku and Force.com
Salesforce Developers
 
Making External Web Pages Interact With Visualforce
Making External Web Pages Interact With VisualforceMaking External Web Pages Interact With Visualforce
Making External Web Pages Interact With Visualforce
Salesforce Developers
 
Bug Hunting with the Salesforce Developer Console
Bug Hunting with the Salesforce Developer ConsoleBug Hunting with the Salesforce Developer Console
Bug Hunting with the Salesforce Developer Console
Matthew Poe
 
Get ready for your platform developer i certification webinar
Get ready for your platform developer i certification   webinarGet ready for your platform developer i certification   webinar
Get ready for your platform developer i certification webinar
JackGuo20
 
Summer '13 Developer Preview Webinar
Summer '13 Developer Preview WebinarSummer '13 Developer Preview Webinar
Summer '13 Developer Preview Webinar
Salesforce Developers
 
Build Consumer-Facing Apps with Heroku Connect
Build Consumer-Facing Apps with Heroku ConnectBuild Consumer-Facing Apps with Heroku Connect
Build Consumer-Facing Apps with Heroku Connect
Jeff Douglas
 
Spring '14 Release Developer Preview Webinar
Spring '14 Release Developer Preview WebinarSpring '14 Release Developer Preview Webinar
Spring '14 Release Developer Preview Webinar
Salesforce Developers
 
Salesforce1 Platform for programmers
Salesforce1 Platform for programmersSalesforce1 Platform for programmers
Salesforce1 Platform for programmers
Salesforce Developers
 
Coding Apps in the Cloud with Force.com - Part 2
Coding Apps in the Cloud with Force.com - Part 2Coding Apps in the Cloud with Force.com - Part 2
Coding Apps in the Cloud with Force.com - Part 2
Salesforce Developers
 
Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex! Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex!
Salesforce Developers
 
Advanced Apex Webinar
Advanced Apex WebinarAdvanced Apex Webinar
Advanced Apex Webinar
pbattisson
 
Design Patterns Every ISV Needs to Know (October 15, 2014)
Design Patterns Every ISV Needs to Know (October 15, 2014)Design Patterns Every ISV Needs to Know (October 15, 2014)
Design Patterns Every ISV Needs to Know (October 15, 2014)
Salesforce Partners
 
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStoreDeveloping Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Tom Gersic
 
Quickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics CloudQuickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics Cloud
Salesforce Developers
 
Elevate workshop programmatic_2014
Elevate workshop programmatic_2014Elevate workshop programmatic_2014
Elevate workshop programmatic_2014
David Scruggs
 
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDKLook Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
Salesforce Developers
 
Hands-on Workshop: Intermediate Development with Heroku and Force.com
Hands-on Workshop: Intermediate Development with Heroku and Force.comHands-on Workshop: Intermediate Development with Heroku and Force.com
Hands-on Workshop: Intermediate Development with Heroku and Force.com
Salesforce Developers
 
Making External Web Pages Interact With Visualforce
Making External Web Pages Interact With VisualforceMaking External Web Pages Interact With Visualforce
Making External Web Pages Interact With Visualforce
Salesforce Developers
 
Bug Hunting with the Salesforce Developer Console
Bug Hunting with the Salesforce Developer ConsoleBug Hunting with the Salesforce Developer Console
Bug Hunting with the Salesforce Developer Console
Matthew Poe
 
Get ready for your platform developer i certification webinar
Get ready for your platform developer i certification   webinarGet ready for your platform developer i certification   webinar
Get ready for your platform developer i certification webinar
JackGuo20
 
Summer '13 Developer Preview Webinar
Summer '13 Developer Preview WebinarSummer '13 Developer Preview Webinar
Summer '13 Developer Preview Webinar
Salesforce Developers
 
Build Consumer-Facing Apps with Heroku Connect
Build Consumer-Facing Apps with Heroku ConnectBuild Consumer-Facing Apps with Heroku Connect
Build Consumer-Facing Apps with Heroku Connect
Jeff Douglas
 
Ad

Recently uploaded (20)

Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 

Asynchronous Apex Salesforce World Tour Paris 2015

  • 2. Samuel De Rycke Salesforce MVP ABSI @SamuelDeRycke Samuel Moyson Developer ABSI @SamuelMoyson Speakers #DevZone #SalesforceWorldTour #AsyncApex
  • 3. 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 intellectual property and other litigation, risks associated with 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-Q for the most recent fiscal quarter ended July 31, 2012. This 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.
  • 4. Follow Developer Force for the Latest News @SalesforceDevs – #SalesforceDevs Developer Force – Force.com Community +Developer Force – Force.com Community Developer Force Developer Force Group
  • 5. Synchronous vs Asynchronous • Synchronous • Asynchronous Process 1 Process 2 Waiting for response Process 1 Process 2 Continues working Get response
  • 6. • Synchronous •Immediate and fast actions •Enforce single, serial, transactions •Normal governor limits • Asynchronous •Actions that should not block the rest of the process •Processes where duration is of lesser concern •Higher governor limits Synchronous vs Asynchronous
  • 7. Types of Asynchronous Apex • Batch Apex • Future Methods • Queueable • Scheduled • Continuation
  • 8. Batch Apex Use when you want to: • Process a big “batch” of records in smaller “batches” of records • Each smaller batch is handled in a discrete transaction • Monitor queue of batch jobs • Batchable context with information about batch
  • 9. Batch Apex Start Execute Finish global Database.QueryLocator start(Database.BatchableContext BC) { //Query for data return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<sObject> scope) { //Do some actions with data //DML Statement } global void finish(Database.BatchableContext BC) { //Give some feedback about statistics of batch //Do post batch actions }
  • 10. Batch Apex Process up to 50 million records Monitor batch progress in the Setup User Interface Admins can reorder batch priority with Apex Flex Queue Maximum 5 concurrent batches processed (status Queued) Not always easy to debug
  • 11. Future Methods Use when you want to: • Execute methods that should not delay or respond to the current Apex transaction • Isolate transaction contexts and DML contexts • Make asynchronous call outs to Web services Pilot: Future methods with Higher Limits • Set specific governor limits for a specific method x2 or x3
  • 12. Future Methods Executepublic class MyClass { public void myNormalMethod{ List<ID> recordIds; //Synchronous logic here myFutureMethod(recordIds); // More synchronous logic } @future public static void myFutureMethod(List<ID> recordIds) { // Get those records based on the IDs // Process records } } @future
  • 13. Future Methods Executed near instantly Bypass mixed DML limitations Pilot: increase limits for specific methods Maximum 50 future methods per Apex invocation Only accepts (collections of) primitive data types Future methods can not invoke other future methods Can not be invoked from Visualforce Constructors, Get & Set
  • 14. Queueable Apex Use when you want to: • Start long-running operations and monitor them within the current process or the user interface • Pass complex types • Chain asynchronous jobs
  • 15. Queueable Apex implements Queueable ID jobID = System.enqueueJob(new MyQueueableJob ()); public class MyQueueableJob implements Queueable { //Other logic public void execute(QueueableContext context) { //Asynchronous logic here //Optionally: enqueue another job } }
  • 16. Queueable Apex Executed near instantly Unlimited depth of chained jobs (except for Dev & Trial orgs) Use sObject and Apex objects as parameters Maximum 50 jobs queued in a single apex transaction When chaining jobs only 1 ‘child job’ is supported Jobs can not be chained in test context. Chained jobs do not support callouts (Winter ‘16 ?)
  • 17. Schedulable Apex Use when you want to: • Schedule Apex classes • Specify schedule with User Interface or Apex
  • 18. Schedulable Apex // Schedulable class global class MySchedulable implements Schedulable { global void execute(SchedulableContext sc) { // Execute apex } } // Schedule from Apex: MySchedulable schApex = new MySchedulable (); String sch = '0 15 10 * * ?'; String jobID = System.schedule('MySchedulable', sch, schApex); implements Schedulable
  • 20. Schedulable Apex Execute Apex on scheduled intervals Admins can manage the schedule from the Setup UI Maximum 100 scheduled jobs at the same time Using the Setup User Interface the minimum interval is 1 hour Synchronous web service callouts are not supported
  • 21. Continuation Use when you want to: –Make callouts from Visualforce pages –Special one: synchronous asynchronous Twitter demo https://github.com/SamuelMoy/TwitterContinuationDemo
  • 23. Continuation // Visualforce page <apex:page showHeader="true" sidebar="true" controller="TwitterController"> <apex:form > <!-- Invokes the action method when the user clicks this button. --> <apex:commandButton action="{!startRequest}" value="Start" reRender="result"/> </apex:form> <!-- This output text component displays the callout response body. --> <apex:outputText id="result" value="{!status} " /> </apex:page> Visualforce
  • 24. Continuation // Action method public Object startRequest() { // Create continuation with a timeout Continuation con = new Continuation(40); // Set callback method con.continuationMethod='processResponse'; HttpRequest req = new HttpRequest(); // Add callout request to continuation this.requestLabel = con.addHttpRequest(req); // Return the continuation return con; } startRequest
  • 25. Continuation // Callback method public Object processResponse() { // Get the response by using the unique label HttpResponse response = Continuation.getResponse(this.requestLabel); // Set the result variable that is displayed on the Visualforce page this.result = response.getBody(); // Return null to re-render the original Visualforce page return null; } processResponse
  • 26. Continuation Integrate Visualforce with back-end systems No long-running concurrent request limit for call outs that last longer than 5 seconds Visualforce page suspended until action completed (= Synchronous) Maximum 3 asynchronous callouts in one single Continuation Maximum timeout continuation is 120 seconds
  • 27. Testing Asynchronous Apex • Invoke asynchronous Apex between the Test.startTest() and Test.stopTest() methods. • The Test.stopTest() method will execute all asynchronous and scheduled Apex synchronously. • Assert :-)
  • 28. Recap Batch Future Schedulable Queueable Continuation High volume of records Near instantly Primitive parameters Schedule jobs Chain jobs Complex parameters Callouts in Visualforce
  • 29. Samuel De Rycke Salesforce MVP ABSI @SamuelDeRycke Samuel Moyson Developer ABSI @SamuelMoyson Q & A
  • 31. La communauté des développeurs Salesforce en France Rejoignez la communauté de développeurs en France et venez partager votre expérience sur la plateforme Salesforce1 bit.ly/dugParis bit.ly/dugStQuentin bit.ly/dugSuisse bit.ly/dugBelgique