Design Patterns for Asynchronous Apex
Dan Appleman, Full Circle CRM, CTO
Author: Advanced Apex Programming for Salesforce....
Safe harbor
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contai...
Our goal today…
Explore how recent changes in Apex support new solutions to
common asynchronous “challenges”
Quick review
▪Why do we use asynchronous code?
▪The big three: Future calls, Batch Apex and Scheduled Apex
▪The Rules
▪ Fu...
What would you like to do?
▪Future calling future
▪Chaining asynchronous operations
▪More frequent and finer resolution sc...
What’s new?
▪Spring 12:

New type system

▪Winter 13:

Start batch in the Finish statement of a batch

▪Summer 13: Increas...
Challenge: Scheduled Apex blocks updates
Solution: Use type system to dynamically create classes that
implement delegated ...
Challenge: Perform a series of batch operations
Solution: Chain batch operations

Code
Start

Execute

Execute

Finish

Ot...
Challenge: Future call can’t call a future call
Solution: Alternate future calls with scheduled Apex

Future

Scheduled

T...
Challenge: Create more than 10 future calls in an
execution context
Solution: Replace future calls with custom async reque...
For more information
Advanced Apex Programming for Salesforce.com and Force.com –
Second Edition
•
•
•
•
•

Incorporates c...
All about Full Circle CRM
Full Circle CRM develops native Salesforce.com applications
that enable marketers to accurately ...
Download sample code for this session at
www.AdvancedApex.com/Dreamforce13
Design Patterns for Asynchronous Apex
Upcoming SlideShare
Loading in...5
×

Design Patterns for Asynchronous Apex

1,182

Published on

Have you ever wanted to schedule an Apex operation to repeat every 10 minutes? To have one future call start another one? Is the 10 future call per context limit getting you down? Recent additions to the Apex language have opened the door to entirely new asynchronous design patterns. Join us to learn about the recent language changes, how they are used, and the kinds of design patterns they enable.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,182
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
53
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Design Patterns for Asynchronous Apex

  1. 1. Design Patterns for Asynchronous Apex Dan Appleman, Full Circle CRM, CTO Author: Advanced Apex Programming for Salesforce.com and Force.com @danappleman
  2. 2. 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.
  3. 3. Our goal today… Explore how recent changes in Apex support new solutions to common asynchronous “challenges”
  4. 4. Quick review ▪Why do we use asynchronous code? ▪The big three: Future calls, Batch Apex and Scheduled Apex ▪The Rules ▪ Future can’t call future, 10 future calls per context ▪ Batch can’t call future, only 5 at once ▪ Limited # of scheduled Apex jobs ▪ Scheduled Apex job blocks updates
  5. 5. What would you like to do? ▪Future calling future ▪Chaining asynchronous operations ▪More frequent and finer resolution scheduled jobs ▪Anything else?
  6. 6. What’s new? ▪Spring 12: New type system ▪Winter 13: Start batch in the Finish statement of a batch ▪Summer 13: Increased # of Scheduled Apex job Scheduled batch ▪Winter 14: CronJobDetail object
  7. 7. Challenge: Scheduled Apex blocks updates Solution: Use type system to dynamically create classes that implement delegated functionality Platform Scheduled Class Dynamic creation Delegated Class
  8. 8. Challenge: Perform a series of batch operations Solution: Chain batch operations Code Start Execute Execute Finish Other batch
  9. 9. Challenge: Future call can’t call a future call Solution: Alternate future calls with scheduled Apex Future Scheduled This design pattern is problematic: •Can burn through limits •Potential concurrency issues Future
  10. 10. Challenge: Create more than 10 future calls in an execution context Solution: Replace future calls with custom async request object Use scheduled Apex or scheduled batch to process requests Insert objects Scheduled Batch “Future” “Future” “Future”
  11. 11. For more information Advanced Apex Programming for Salesforce.com and Force.com – Second Edition • • • • • Incorporates changes through Winter 14 Designing for CPU Time limits Extended chapter on triggers Extended chapter on asynchronous patterns New chapter on concurrency patterns
  12. 12. All about Full Circle CRM Full Circle CRM develops native Salesforce.com applications that enable marketers to accurately track and measure marketing campaign performance directly in Salesforce ▪ Bridge the information gap between leads and contacts ▪ Obtain complete and detailed campaign performance metrics ▪ Develop advanced campaign attribution and influence analytics Booth 1324 Moscone North
  13. 13. Download sample code for this session at www.AdvancedApex.com/Dreamforce13
  1. ¿Le ha llamado la atención una diapositiva en particular?

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×