SlideShare a Scribd company logo
1 of 12
Truly Asynchronous Apex Triggers
Using Change Data Capture
jbrock@salesforce.com, @_ johnbrock
John Brock
Product Management
Yasaman Mohsenin
Engineering Management
ymohsenin@salesforce.com
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.
Statement under the Private Securities Litigation Reform Act of 1995
Forward-Looking Statement
Key Systems Need Up-To-Date Information
Businesses need to replicate changes in Salesforce to maintain consistency
Account {
Name : ”Acme"
}
Account {
?
}
Account {
?
}
New Account=’Acme’;
CRM Other Key Applications
Capture changes without custom code
Easily select objects to capture data changes on with clicks
Keep your key systems up to date
Ensure downstream systems always have the right data
Scale with ease to millions of events daily
Events are held for 72-hours to prevent data loss
Change Data Capture
Generally
Available
12/18
Detect changes on Salesforce records in real-time
No polling
No batch ETL processes
No point-to-point integrations
“/data/ChangeEvents” Channel
Account {
Name : “Acme”
}
Account {
Name :
“Acme”
}
Account {
Name :
“Acme”
}
Change Data Capture Unlocks Real-Time Data Sync
Data Replication
Process
Automation
Audit &
Compliance
Salesforce Event Bus
/closed_won
/new_account
/new_account
/data_change
Update external
systems to reflect
changes in Salesforce
Downstream systems
react when Salesforce
data changes
Changes in Salesforce
must be stored for an
extended period of time
Asynchronous Apex Triggers
A brand-new construct for Salesforce Platform
Apex Triggers
Customizable business logic written natively on Platform
Transactional Execution
Trigger logic is executed and is guaranteed to be complete
before the data is committed
Seamless Interaction Experience
End-users get instant feedback for input errors, logic
decisions, and computation results
Tightly Coupled with DML Operations
All processing, triggers, updates are considered one unit of
work that completely succeeds or rolls back
trigger CaseTrigger on Case (after insert) {
// Setup
....
// Perform logic
....
// Cleanup / Finish
....
}
Async Apex Triggers
Complex computations and logic executed outside of the transaction
True Post-Commit Execution
Triggers execute asynchronously after a transaction
Faster End-user Experience
Less logic and computation inside the transaction leads to
quicker end-user experiences and fewer limit concerns
Event-driven and Decoupled
Errors in processing won’t rollback or impact the transaction
trigger CaseChangeEventTrigger on CaseChangeEvent (after insert) {
// Setup
....
// Perform heavy (slow) computation
....
// Cleanup / Finish
....
}
When should I use Async Triggers?
Any calculation or piece of logic that can happen after the data is changed
Keep critical logic in the transaction
Data validation, data consistency, and required prerequisite
operations before data is changed
Processing that can happen “later”
-- Heavyweight computations
-- Einstein (or other ML/AI) operations
-- Notifications to other systems
-- Joining of data from different sources
-- Summary calculations
trigger CaseChangeEventTrigger on CaseChangeEvent (after insert) {
List<CaseChangeEvent> changes = Trigger.new;
Set<String> caseIds = new Set<String>();
// Get all Record Ids for this change
for (CaseChangeEvent change : changes) {
List<String> recordIds = change.ChangeEventHeader.getRecordIds();
caseIds.addAll(recordIds);
}
// Perform heavy (slow) computation determining Red Account
RedAccountPredictor predictor = new RedAccountPredictor();
Map<String, boolean> accountsToRedAccountStatus =
predictor.predictForCases(new List<String>(caseIds));
// Publish platform events for predicted red accounts
List<Red_Account__e> redAccountEvents = new List<Red_Account__e>();
for (String acctId : accountsToRedAccountStatus.keySet()) {
if (rating=='Red') {
redAccountEvents.add(new Red_Account__e(Account_Id__c=acctId, Rating__c=rating));
}
}
if (redAccountEvents.size() > 0) {
EventBus.publish(redAccountEvents);
}
}
Demo
An async demo in real-time
Dive into Change Data Capture on Trailhead!
Learn more
Details, use-cases, and getting-started guides
[Blog] What is Change Data Capture
[Blog] What Streaming Event Should I Use?
Dreamforce 18 : Change Data Capture (20 min)
Dreamforce 18 : Platform Events (20 min)
Dev Guide : Change Data Capture
Get Hands-On with
Automation Workshops
Build Together
on the Low
Code Platform
Thurs. 11am PT
See demos, join a workshop,
ask questions & more!
Visit us at Platform Point
Floor 1
3rd Floor
Keynote Room
Super Sessions:
Salesforce <3 DX
Weds at 3:00 PM
Build Together
with Low Code
Thurs at 11:00 AM

More Related Content

What's hot

Clearpriority Operational Intelligence Platform
Clearpriority Operational Intelligence PlatformClearpriority Operational Intelligence Platform
Clearpriority Operational Intelligence PlatformClearpriority
 
Lightning Flow Actions
Lightning Flow ActionsLightning Flow Actions
Lightning Flow Actionsmisswlee
 
100+ tasks that can automated with RPA
100+ tasks that can automated with RPA100+ tasks that can automated with RPA
100+ tasks that can automated with RPAPaul Scott
 
Ritz Automation Brochure 2014
Ritz Automation Brochure 2014Ritz Automation Brochure 2014
Ritz Automation Brochure 2014Lloyd Rietze
 
ERP on SAP B1-MegathermITS
ERP on SAP B1-MegathermITSERP on SAP B1-MegathermITS
ERP on SAP B1-MegathermITSArindam Sinha
 
Duplicate Payments Analysis - FTSE100 construction company
Duplicate Payments Analysis - FTSE100 construction companyDuplicate Payments Analysis - FTSE100 construction company
Duplicate Payments Analysis - FTSE100 construction companyAlex Psarras
 
Equities portfolio management
Equities portfolio managementEquities portfolio management
Equities portfolio managementStrategybeach
 
Data import options- Salesforce Dreamforce presentation
Data import options- Salesforce Dreamforce presentationData import options- Salesforce Dreamforce presentation
Data import options- Salesforce Dreamforce presentationRich Spitz
 
Alignia for Business Applications
Alignia for Business ApplicationsAlignia for Business Applications
Alignia for Business ApplicationsLaurie LeBlanc
 
Software Asset Management – Keeping track of what I’m licensed for!
Software Asset Management – Keeping track of what I’m licensed for!Software Asset Management – Keeping track of what I’m licensed for!
Software Asset Management – Keeping track of what I’m licensed for!Cireson
 
Durable Streaming and Enterprise Messaging
Durable Streaming and Enterprise MessagingDurable Streaming and Enterprise Messaging
Durable Streaming and Enterprise MessagingSalesforce Developers
 
Streaming api with generic and durable streaming
Streaming api with generic and durable streamingStreaming api with generic and durable streaming
Streaming api with generic and durable streamingPeter Chittum
 
Office of Finance
Office of FinanceOffice of Finance
Office of FinanceFlexera
 
InfraStitch Software Presentation
InfraStitch Software PresentationInfraStitch Software Presentation
InfraStitch Software PresentationSwapan Deb
 

What's hot (17)

Clearpriority Operational Intelligence Platform
Clearpriority Operational Intelligence PlatformClearpriority Operational Intelligence Platform
Clearpriority Operational Intelligence Platform
 
Intellica Event and Action Manager
Intellica Event and Action ManagerIntellica Event and Action Manager
Intellica Event and Action Manager
 
Lightning Flow Actions
Lightning Flow ActionsLightning Flow Actions
Lightning Flow Actions
 
100+ tasks that can automated with RPA
100+ tasks that can automated with RPA100+ tasks that can automated with RPA
100+ tasks that can automated with RPA
 
Ritz Automation Brochure 2014
Ritz Automation Brochure 2014Ritz Automation Brochure 2014
Ritz Automation Brochure 2014
 
ERP on SAP B1-MegathermITS
ERP on SAP B1-MegathermITSERP on SAP B1-MegathermITS
ERP on SAP B1-MegathermITS
 
Streaming API with Java
Streaming API with JavaStreaming API with Java
Streaming API with Java
 
Duplicate Payments Analysis - FTSE100 construction company
Duplicate Payments Analysis - FTSE100 construction companyDuplicate Payments Analysis - FTSE100 construction company
Duplicate Payments Analysis - FTSE100 construction company
 
Equities portfolio management
Equities portfolio managementEquities portfolio management
Equities portfolio management
 
Data import options- Salesforce Dreamforce presentation
Data import options- Salesforce Dreamforce presentationData import options- Salesforce Dreamforce presentation
Data import options- Salesforce Dreamforce presentation
 
Alignia for Business Applications
Alignia for Business ApplicationsAlignia for Business Applications
Alignia for Business Applications
 
Software Asset Management – Keeping track of what I’m licensed for!
Software Asset Management – Keeping track of what I’m licensed for!Software Asset Management – Keeping track of what I’m licensed for!
Software Asset Management – Keeping track of what I’m licensed for!
 
Durable Streaming and Enterprise Messaging
Durable Streaming and Enterprise MessagingDurable Streaming and Enterprise Messaging
Durable Streaming and Enterprise Messaging
 
Product overviews (2)
Product overviews (2)Product overviews (2)
Product overviews (2)
 
Streaming api with generic and durable streaming
Streaming api with generic and durable streamingStreaming api with generic and durable streaming
Streaming api with generic and durable streaming
 
Office of Finance
Office of FinanceOffice of Finance
Office of Finance
 
InfraStitch Software Presentation
InfraStitch Software PresentationInfraStitch Software Presentation
InfraStitch Software Presentation
 

Similar to TrailheaDX 2019 : Truly Asynchronous Apex Triggers using Change Data Capture

Event Driven Integrations
Event Driven IntegrationsEvent Driven Integrations
Event Driven IntegrationsDeepu Chacko
 
Df14 Building Machine Learning Systems with Apex
Df14 Building Machine Learning Systems with ApexDf14 Building Machine Learning Systems with Apex
Df14 Building Machine Learning Systems with Apexpbattisson
 
Singapore dg salesforce einstein + spring 17 release by manish
Singapore dg   salesforce einstein + spring 17 release by manishSingapore dg   salesforce einstein + spring 17 release by manish
Singapore dg salesforce einstein + spring 17 release by manishManish Thaduri
 
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 FieldSalesforce Developers
 
Advanced Apex Development - Asynchronous Processes
Advanced Apex Development - Asynchronous ProcessesAdvanced Apex Development - Asynchronous Processes
Advanced Apex Development - Asynchronous ProcessesSalesforce Developers
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPSalesforce Developers
 
Integration Strategies in a SaaS Environment
Integration Strategies in a SaaS EnvironmentIntegration Strategies in a SaaS Environment
Integration Strategies in a SaaS Environmentdreamforce2006
 
Visualforce Hack for Junction Objects
Visualforce Hack for Junction ObjectsVisualforce Hack for Junction Objects
Visualforce Hack for Junction ObjectsRitesh Aswaney
 
HBaseCon 2015: NRT Event Processing with Guaranteed Delivery of HTTP Callbacks
HBaseCon 2015: NRT Event Processing with Guaranteed Delivery of HTTP CallbacksHBaseCon 2015: NRT Event Processing with Guaranteed Delivery of HTTP Callbacks
HBaseCon 2015: NRT Event Processing with Guaranteed Delivery of HTTP CallbacksHBaseCon
 
NRT Event Processing with Guaranteed Delivery of HTTP Callbacks, HBaseCon 2015
NRT Event Processing with Guaranteed Delivery of HTTP Callbacks, HBaseCon 2015NRT Event Processing with Guaranteed Delivery of HTTP Callbacks, HBaseCon 2015
NRT Event Processing with Guaranteed Delivery of HTTP Callbacks, HBaseCon 2015Cask Data
 
Integrating Salesforce and QuickBooks
Integrating Salesforce and QuickBooksIntegrating Salesforce and QuickBooks
Integrating Salesforce and QuickBooksdreamforce2006
 
Lightning components performance best practices
Lightning components performance best practicesLightning components performance best practices
Lightning components performance best practicesSalesforce Developers
 
Getting to Grips with Process Builder
Getting to Grips with Process BuilderGetting to Grips with Process Builder
Getting to Grips with Process BuilderRichard Clark
 
Enhancing Your Lightning Apps with Einstein Analytics
Enhancing Your Lightning Apps with Einstein AnalyticsEnhancing Your Lightning Apps with Einstein Analytics
Enhancing Your Lightning Apps with Einstein Analyticsrikkehovgaard
 
Building Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersBuilding Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersSalesforce Developers
 
Integrating Salesforce and QuickBooks
Integrating Salesforce and QuickBooksIntegrating Salesforce and QuickBooks
Integrating Salesforce and QuickBooksdreamforce2006
 

Similar to TrailheaDX 2019 : Truly Asynchronous Apex Triggers using Change Data Capture (20)

Event Driven Integrations
Event Driven IntegrationsEvent Driven Integrations
Event Driven Integrations
 
Introduction to Apex Triggers
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex Triggers
 
Df14 Building Machine Learning Systems with Apex
Df14 Building Machine Learning Systems with ApexDf14 Building Machine Learning Systems with Apex
Df14 Building Machine Learning Systems with Apex
 
Singapore dg salesforce einstein + spring 17 release by manish
Singapore dg   salesforce einstein + spring 17 release by manishSingapore dg   salesforce einstein + spring 17 release by manish
Singapore dg salesforce einstein + spring 17 release by manish
 
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
 
Advanced Apex Development - Asynchronous Processes
Advanced Apex Development - Asynchronous ProcessesAdvanced Apex Development - Asynchronous Processes
Advanced Apex Development - Asynchronous Processes
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCP
 
Integration Strategies in a SaaS Environment
Integration Strategies in a SaaS EnvironmentIntegration Strategies in a SaaS Environment
Integration Strategies in a SaaS Environment
 
Visualforce Hack for Junction Objects
Visualforce Hack for Junction ObjectsVisualforce Hack for Junction Objects
Visualforce Hack for Junction Objects
 
HBaseCon 2015: NRT Event Processing with Guaranteed Delivery of HTTP Callbacks
HBaseCon 2015: NRT Event Processing with Guaranteed Delivery of HTTP CallbacksHBaseCon 2015: NRT Event Processing with Guaranteed Delivery of HTTP Callbacks
HBaseCon 2015: NRT Event Processing with Guaranteed Delivery of HTTP Callbacks
 
NRT Event Processing with Guaranteed Delivery of HTTP Callbacks, HBaseCon 2015
NRT Event Processing with Guaranteed Delivery of HTTP Callbacks, HBaseCon 2015NRT Event Processing with Guaranteed Delivery of HTTP Callbacks, HBaseCon 2015
NRT Event Processing with Guaranteed Delivery of HTTP Callbacks, HBaseCon 2015
 
Force.com Friday : Intro to Apex
Force.com Friday : Intro to Apex Force.com Friday : Intro to Apex
Force.com Friday : Intro to Apex
 
Introduction to Apex Triggers
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex Triggers
 
Integrating Salesforce and QuickBooks
Integrating Salesforce and QuickBooksIntegrating Salesforce and QuickBooks
Integrating Salesforce and QuickBooks
 
Lightning components performance best practices
Lightning components performance best practicesLightning components performance best practices
Lightning components performance best practices
 
Getting to Grips with Process Builder
Getting to Grips with Process BuilderGetting to Grips with Process Builder
Getting to Grips with Process Builder
 
Wielding Workflow
Wielding WorkflowWielding Workflow
Wielding Workflow
 
Enhancing Your Lightning Apps with Einstein Analytics
Enhancing Your Lightning Apps with Einstein AnalyticsEnhancing Your Lightning Apps with Einstein Analytics
Enhancing Your Lightning Apps with Einstein Analytics
 
Building Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersBuilding Visualforce Custom Events Handlers
Building Visualforce Custom Events Handlers
 
Integrating Salesforce and QuickBooks
Integrating Salesforce and QuickBooksIntegrating Salesforce and QuickBooks
Integrating Salesforce and QuickBooks
 

Recently uploaded

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Recently uploaded (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

TrailheaDX 2019 : Truly Asynchronous Apex Triggers using Change Data Capture

  • 1. Truly Asynchronous Apex Triggers Using Change Data Capture jbrock@salesforce.com, @_ johnbrock John Brock Product Management Yasaman Mohsenin Engineering Management ymohsenin@salesforce.com
  • 2. 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. Statement under the Private Securities Litigation Reform Act of 1995 Forward-Looking Statement
  • 3. Key Systems Need Up-To-Date Information Businesses need to replicate changes in Salesforce to maintain consistency Account { Name : ”Acme" } Account { ? } Account { ? } New Account=’Acme’; CRM Other Key Applications
  • 4. Capture changes without custom code Easily select objects to capture data changes on with clicks Keep your key systems up to date Ensure downstream systems always have the right data Scale with ease to millions of events daily Events are held for 72-hours to prevent data loss Change Data Capture Generally Available 12/18 Detect changes on Salesforce records in real-time No polling No batch ETL processes No point-to-point integrations “/data/ChangeEvents” Channel Account { Name : “Acme” } Account { Name : “Acme” } Account { Name : “Acme” }
  • 5. Change Data Capture Unlocks Real-Time Data Sync Data Replication Process Automation Audit & Compliance Salesforce Event Bus /closed_won /new_account /new_account /data_change Update external systems to reflect changes in Salesforce Downstream systems react when Salesforce data changes Changes in Salesforce must be stored for an extended period of time
  • 6. Asynchronous Apex Triggers A brand-new construct for Salesforce Platform
  • 7. Apex Triggers Customizable business logic written natively on Platform Transactional Execution Trigger logic is executed and is guaranteed to be complete before the data is committed Seamless Interaction Experience End-users get instant feedback for input errors, logic decisions, and computation results Tightly Coupled with DML Operations All processing, triggers, updates are considered one unit of work that completely succeeds or rolls back trigger CaseTrigger on Case (after insert) { // Setup .... // Perform logic .... // Cleanup / Finish .... }
  • 8. Async Apex Triggers Complex computations and logic executed outside of the transaction True Post-Commit Execution Triggers execute asynchronously after a transaction Faster End-user Experience Less logic and computation inside the transaction leads to quicker end-user experiences and fewer limit concerns Event-driven and Decoupled Errors in processing won’t rollback or impact the transaction trigger CaseChangeEventTrigger on CaseChangeEvent (after insert) { // Setup .... // Perform heavy (slow) computation .... // Cleanup / Finish .... }
  • 9. When should I use Async Triggers? Any calculation or piece of logic that can happen after the data is changed Keep critical logic in the transaction Data validation, data consistency, and required prerequisite operations before data is changed Processing that can happen “later” -- Heavyweight computations -- Einstein (or other ML/AI) operations -- Notifications to other systems -- Joining of data from different sources -- Summary calculations trigger CaseChangeEventTrigger on CaseChangeEvent (after insert) { List<CaseChangeEvent> changes = Trigger.new; Set<String> caseIds = new Set<String>(); // Get all Record Ids for this change for (CaseChangeEvent change : changes) { List<String> recordIds = change.ChangeEventHeader.getRecordIds(); caseIds.addAll(recordIds); } // Perform heavy (slow) computation determining Red Account RedAccountPredictor predictor = new RedAccountPredictor(); Map<String, boolean> accountsToRedAccountStatus = predictor.predictForCases(new List<String>(caseIds)); // Publish platform events for predicted red accounts List<Red_Account__e> redAccountEvents = new List<Red_Account__e>(); for (String acctId : accountsToRedAccountStatus.keySet()) { if (rating=='Red') { redAccountEvents.add(new Red_Account__e(Account_Id__c=acctId, Rating__c=rating)); } } if (redAccountEvents.size() > 0) { EventBus.publish(redAccountEvents); } }
  • 10. Demo An async demo in real-time
  • 11.
  • 12. Dive into Change Data Capture on Trailhead! Learn more Details, use-cases, and getting-started guides [Blog] What is Change Data Capture [Blog] What Streaming Event Should I Use? Dreamforce 18 : Change Data Capture (20 min) Dreamforce 18 : Platform Events (20 min) Dev Guide : Change Data Capture Get Hands-On with Automation Workshops Build Together on the Low Code Platform Thurs. 11am PT See demos, join a workshop, ask questions & more! Visit us at Platform Point Floor 1 3rd Floor Keynote Room Super Sessions: Salesforce <3 DX Weds at 3:00 PM Build Together with Low Code Thurs at 11:00 AM