SlideShare una empresa de Scribd logo
1 de 19
Platform Events
Salesforce’s Event-Driven Software Architecture
timdt01@gmail.com
Tim Taylor, Jacksonville Developer Group member.
What is an Event-Driven Software Architecture?
Event-Driven Software Architecture
● Consists of event producers, event consumers, and channels.
● Suitable for large distributed systems
● Decouples event producers from the event consumers.
● Components:
● Event: change in state meaningful to business
● Event Message: data about the event
● Producer: publisher of the event message over channel
● Channel: conduit to transmit the event
● Consumer: subscribes to a channel to receive event.
Custom Platform Events
● Platform events are messages that are
published and subscribed to.
● One or more subscribers can listen to
the same event and carry out
independent actions.
● This way, key components of an
integration are decoupled.
● Define a custom event in same way as
custom objects.
● Create the event by giving it a name and
adding custom fields.
Publishing Platform Events
● You can publish platform events by:
● Apex code.
● Point and click tools such as Process Builder and Flow Builder.
● Any Salesforce API from external applications.
● SOAP, REST or Bulk API
Platform Event
External
App
Salesforce
Trigger
REST API APEX
Apex Published Events
● To publish event messages by Apex, call the EventBus.publish() method passing an
instance of the custom event.
Process Builder Published Events
● Add a Create a Record action.
● For the Record Type, select the
custom platform event.
● Populate the fields of the platform
event.
API Published Events
● External applications use an
API to publish event
messages.
● You can use any Salesforce
API to create events in same
way as you would insert
sObjects.
● To publish multiple event
messages use the
composite resource.
REST endpoint:
/services/data/v47.0/sobjects/Registration_Notification__e
Request body:
{
"CaseId__c":"5008A000006GvpKQAS"
}
REST response:
{
"id" : "e01xx0000000001AAA",
"success" : true,
"errors" : [ {
"statusCode" : "OPERATION_ENQUEUED",
"message" : "154dba26-db92-4557-ad6b-9c7222428346",
"fields" : [ ]
} ]
}
Subscribing to Platform Events
● You can subscribe to platform events by:
● Apex Triggers.
● Point and click tools such as Process Builder and Flow Builder.
● Lightning apps can subscribe through the empApi component.
● Through CometD in external apps.
Platform Event
CometD
Apex Trigger
Process/Flow
Subscribing to Events with Apex Triggers
● Triggers provide an auto subscription mechanism in Apex. No need to explicitly create
and listen to a channel.
● Platform events ONLY support after insert triggers.
Subscribing to Events with Processes
● Processes also provide an auto
subscription mechanism for
published events. No need to
explicitly create and listen to a
channel.
● To subscribe to a platform
event, build the process to
start when it receives an event
message.
● Then associate the process
with a platform event and an
object
Subscribing to Events with Lightning Components
● Subscribe to platform events with
empApi component
● In Lightning Web components import
the methods from the lightning/empApi
module and then call the imported
methods from your javascript code.
● In Aura components add the
lightning:empApi component in your
markup and then add functions to call
the component methods in your client-
side controller.
Lightning Web Component:
Import { subscribe, unsubscribe, onError, }
from ‘lightning/empApi’;
Lightning Aura Component:
<lightning:empApi aura:id=“empApi” />
Subscribing to Events with CometD
● External systems can subscribe to
platform events using CometD
● The entities that consume platform
events should subscribe to the event’s
channel.
The platform event for our example:
/event/Registration_Notification__e
Event message when received:
{
"data": {
"schema":"dffQ2QLzDNHqwB8_sHMxdA",
"payload": {
"CreatedDate": "2020-03-09T18:31:40.517Z",
"CreatedById": "005D0000001cSZs",
"CaseId__c":"5008A000006GvpKQAS"
},
"event": {
"replayId": 1
}
},
"channel": "/event/Registration_Notification__e“
}
Automatic Retry Capabilities When Errors Occur
● Helpful to retry consuming an event when a transient error occurs.
● This is only available with event triggers.
● Retry events by throwing the EventBus.RetryableException.
Resuming a Platform Event
● If a trigger stops execution intentionally or because of unhandled exception
● Set a checkpoint to resume by setting replay ID of last successful event message.
● EventBus.TriggerContext.currentContext().setResumeCheckpoint(event.replayId)
Business Need – Organization Registration Notification
Salesforce is integrated with JIRA to allow for synchronization of JIRA tickets with the corresponding
Salesforce cases.
Organizations register with Availity daily. Some of those registrations are flagged for follow up for additional
information and a JIRA ticket is created along with a corresponding Salesforce case.
Our Fraud Analysts, working in JIRA, identify the necessary information needed and apply a series of labels
to the JIRA ticket and update the ticket status to Awaiting Reply. The Salesforce case is automatically
updated with this information.
The client support organization then manually reviews those labels and sends an email to the customer by
concatenating a series of Lightning Email Templates that correspond to the labels assigned to the case.
There are dozens of these registrations daily that often pile up for processing.
The Goal is to remove the manual process of sending the notifications to customers.
Apex Class
Solution – Organization Registration Notification
Platform Event
Process
Publishes Event
JIRA
Ticket
Salesforce
Case
Apex Trigger
REST API
Trigger Subscribes to
Event
“DEMO TIME!”
hope it works!
What’s Next?
How can I learn more about Platform Events?
Platform Events Developer Guide
https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_intro.htm
Platform Events Basics
https://trailhead.salesforce.com/en/content/learn/modules/platform_events_basics
Platform Events by Tim Taylor

Más contenido relacionado

La actualidad más candente

Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforceMark Adcock
 
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
 
Salesforce Presentation
Salesforce PresentationSalesforce Presentation
Salesforce PresentationChetna Purohit
 
Salesforce Streaming Api
Salesforce Streaming ApiSalesforce Streaming Api
Salesforce Streaming ApiJayant Jindal
 
Two-Way Integration with Writable External Objects
Two-Way Integration with Writable External ObjectsTwo-Way Integration with Writable External Objects
Two-Way Integration with Writable External ObjectsSalesforce Developers
 
Salesforce Security Model (Dmitry Goshko, Igor Haritonovich)
Salesforce Security Model (Dmitry Goshko, Igor Haritonovich)Salesforce Security Model (Dmitry Goshko, Igor Haritonovich)
Salesforce Security Model (Dmitry Goshko, Igor Haritonovich)Yury Bondarau
 
Best Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdfBest Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdfMohith Shrivastava
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureSalesforce Developers
 
Salesforce Integration
Salesforce IntegrationSalesforce Integration
Salesforce IntegrationJoshua Hoskins
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilitySalesforce Developers
 
Salesforce admin training 1
Salesforce admin training 1Salesforce admin training 1
Salesforce admin training 1HungPham381
 
Managing the Role Hierarchy at Enterprise Scale
Managing the Role Hierarchy at Enterprise ScaleManaging the Role Hierarchy at Enterprise Scale
Managing the Role Hierarchy at Enterprise ScaleSalesforce Developers
 
Salesforce developer training presentation slides
Salesforce developer training presentation slidesSalesforce developer training presentation slides
Salesforce developer training presentation slidesSalesforce Associates
 
Vlocity Order Management - Fernando Reich
Vlocity Order Management - Fernando ReichVlocity Order Management - Fernando Reich
Vlocity Order Management - Fernando ReichFernando Reich
 
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSalesforce Developers
 
15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood
15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood
15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan OsgoodSalesforce Admins
 
Salesforce and SAP Integration with Informatica Cloud
Salesforce and SAP Integration with Informatica CloudSalesforce and SAP Integration with Informatica Cloud
Salesforce and SAP Integration with Informatica CloudDarren Cunningham
 
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...Sam Garforth
 

La actualidad más candente (20)

Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforce
 
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 Presentation
Salesforce PresentationSalesforce Presentation
Salesforce Presentation
 
Architect day 20181128 - Afternoon Session
Architect day 20181128 - Afternoon SessionArchitect day 20181128 - Afternoon Session
Architect day 20181128 - Afternoon Session
 
Salesforce Streaming Api
Salesforce Streaming ApiSalesforce Streaming Api
Salesforce Streaming Api
 
Two-Way Integration with Writable External Objects
Two-Way Integration with Writable External ObjectsTwo-Way Integration with Writable External Objects
Two-Way Integration with Writable External Objects
 
Salesforce Security Model (Dmitry Goshko, Igor Haritonovich)
Salesforce Security Model (Dmitry Goshko, Igor Haritonovich)Salesforce Security Model (Dmitry Goshko, Igor Haritonovich)
Salesforce Security Model (Dmitry Goshko, Igor Haritonovich)
 
Best Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdfBest Practices with Apex in 2022.pdf
Best Practices with Apex in 2022.pdf
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data Capture
 
Salesforce Integration
Salesforce IntegrationSalesforce Integration
Salesforce Integration
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Salesforce admin training 1
Salesforce admin training 1Salesforce admin training 1
Salesforce admin training 1
 
Managing the Role Hierarchy at Enterprise Scale
Managing the Role Hierarchy at Enterprise ScaleManaging the Role Hierarchy at Enterprise Scale
Managing the Role Hierarchy at Enterprise Scale
 
Salesforce developer training presentation slides
Salesforce developer training presentation slidesSalesforce developer training presentation slides
Salesforce developer training presentation slides
 
Introduction to Apex for Developers
Introduction to Apex for DevelopersIntroduction to Apex for Developers
Introduction to Apex for Developers
 
Vlocity Order Management - Fernando Reich
Vlocity Order Management - Fernando ReichVlocity Order Management - Fernando Reich
Vlocity Order Management - Fernando Reich
 
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
 
15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood
15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood
15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood
 
Salesforce and SAP Integration with Informatica Cloud
Salesforce and SAP Integration with Informatica CloudSalesforce and SAP Integration with Informatica Cloud
Salesforce and SAP Integration with Informatica Cloud
 
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
Salesforce Application Lifecycle Management presented to EA Forum by Sam Garf...
 

Similar a Platform Events by Tim Taylor

Apex Replay Debugger and Salesforce Platform Events.pptx
Apex Replay Debugger and Salesforce Platform Events.pptxApex Replay Debugger and Salesforce Platform Events.pptx
Apex Replay Debugger and Salesforce Platform Events.pptxmohayyudin7826
 
Platform events
Platform eventsPlatform events
Platform eventsarun jain
 
PlatForm Event.pptx
PlatForm Event.pptxPlatForm Event.pptx
PlatForm Event.pptxRinku Saini
 
ISV Monthly Tech Enablement (August 2017)
ISV Monthly Tech Enablement (August 2017)ISV Monthly Tech Enablement (August 2017)
ISV Monthly Tech Enablement (August 2017)Salesforce Partners
 
FIWARE Complex Event Processing
FIWARE Complex Event ProcessingFIWARE Complex Event Processing
FIWARE Complex Event ProcessingMiguel González
 
Event-Based API Patterns and Practices
Event-Based API Patterns and PracticesEvent-Based API Patterns and Practices
Event-Based API Patterns and PracticesLaunchAny
 
Microsoft Graph API with OutSystems Event Subscriptions
Microsoft Graph API with OutSystems Event SubscriptionsMicrosoft Graph API with OutSystems Event Subscriptions
Microsoft Graph API with OutSystems Event SubscriptionsStefan Weber
 
Extending WSO2 Analytics Platform
Extending WSO2 Analytics PlatformExtending WSO2 Analytics Platform
Extending WSO2 Analytics PlatformWSO2
 
[Webinar] Camunda Optimize Release 3.0
[Webinar] Camunda Optimize Release 3.0[Webinar] Camunda Optimize Release 3.0
[Webinar] Camunda Optimize Release 3.0camunda services GmbH
 
ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017Lucas Jellema
 
TrailheaDX 2019 : Explore New Frontiers with High Volume Platform Events
TrailheaDX 2019 :  Explore New Frontiers with High Volume Platform EventsTrailheaDX 2019 :  Explore New Frontiers with High Volume Platform Events
TrailheaDX 2019 : Explore New Frontiers with High Volume Platform EventsJohn Brock
 
Bloomberg API Open Source Development and Solution Providers India
Bloomberg API Open Source Development and Solution Providers IndiaBloomberg API Open Source Development and Solution Providers India
Bloomberg API Open Source Development and Solution Providers IndiaPoint Perfect Technology Solutions
 
Publish and subscribe platform events using flows
Publish and subscribe platform events using flowsPublish and subscribe platform events using flows
Publish and subscribe platform events using flowsKadharBashaJ
 
Platform Events Demo (1).pptx
Platform Events Demo (1).pptxPlatform Events Demo (1).pptx
Platform Events Demo (1).pptxDileepSingh682144
 
Understanding Business APIs through statistics
Understanding Business APIs through statisticsUnderstanding Business APIs through statistics
Understanding Business APIs through statisticsWSO2
 
Event Mesh Presentation at Gartner AADI Mumbai
Event Mesh Presentation at Gartner AADI MumbaiEvent Mesh Presentation at Gartner AADI Mumbai
Event Mesh Presentation at Gartner AADI MumbaiSolace
 
Notification Service 2005
Notification Service 2005Notification Service 2005
Notification Service 2005shram2k
 

Similar a Platform Events by Tim Taylor (20)

Apex Replay Debugger and Salesforce Platform Events.pptx
Apex Replay Debugger and Salesforce Platform Events.pptxApex Replay Debugger and Salesforce Platform Events.pptx
Apex Replay Debugger and Salesforce Platform Events.pptx
 
Platform events
Platform eventsPlatform events
Platform events
 
PlatForm Event.pptx
PlatForm Event.pptxPlatForm Event.pptx
PlatForm Event.pptx
 
ISV Monthly Tech Enablement (August 2017)
ISV Monthly Tech Enablement (August 2017)ISV Monthly Tech Enablement (August 2017)
ISV Monthly Tech Enablement (August 2017)
 
FIWARE Complex Event Processing
FIWARE Complex Event ProcessingFIWARE Complex Event Processing
FIWARE Complex Event Processing
 
FIWARE Complex Event Processing
FIWARE Complex Event ProcessingFIWARE Complex Event Processing
FIWARE Complex Event Processing
 
Event-Based API Patterns and Practices
Event-Based API Patterns and PracticesEvent-Based API Patterns and Practices
Event-Based API Patterns and Practices
 
Microsoft Graph API with OutSystems Event Subscriptions
Microsoft Graph API with OutSystems Event SubscriptionsMicrosoft Graph API with OutSystems Event Subscriptions
Microsoft Graph API with OutSystems Event Subscriptions
 
SAP workflow events
SAP workflow eventsSAP workflow events
SAP workflow events
 
Extending WSO2 Analytics Platform
Extending WSO2 Analytics PlatformExtending WSO2 Analytics Platform
Extending WSO2 Analytics Platform
 
[Webinar] Camunda Optimize Release 3.0
[Webinar] Camunda Optimize Release 3.0[Webinar] Camunda Optimize Release 3.0
[Webinar] Camunda Optimize Release 3.0
 
ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017
 
TrailheaDX 2019 : Explore New Frontiers with High Volume Platform Events
TrailheaDX 2019 :  Explore New Frontiers with High Volume Platform EventsTrailheaDX 2019 :  Explore New Frontiers with High Volume Platform Events
TrailheaDX 2019 : Explore New Frontiers with High Volume Platform Events
 
Bloomberg API Open Source Development and Solution Providers India
Bloomberg API Open Source Development and Solution Providers IndiaBloomberg API Open Source Development and Solution Providers India
Bloomberg API Open Source Development and Solution Providers India
 
Publish and subscribe platform events using flows
Publish and subscribe platform events using flowsPublish and subscribe platform events using flows
Publish and subscribe platform events using flows
 
Platform Events Demo (1).pptx
Platform Events Demo (1).pptxPlatform Events Demo (1).pptx
Platform Events Demo (1).pptx
 
Understanding Business APIs through statistics
Understanding Business APIs through statisticsUnderstanding Business APIs through statistics
Understanding Business APIs through statistics
 
4.out port
4.out port4.out port
4.out port
 
Event Mesh Presentation at Gartner AADI Mumbai
Event Mesh Presentation at Gartner AADI MumbaiEvent Mesh Presentation at Gartner AADI Mumbai
Event Mesh Presentation at Gartner AADI Mumbai
 
Notification Service 2005
Notification Service 2005Notification Service 2005
Notification Service 2005
 

Último

Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 

Último (20)

Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 

Platform Events by Tim Taylor

  • 1. Platform Events Salesforce’s Event-Driven Software Architecture timdt01@gmail.com Tim Taylor, Jacksonville Developer Group member.
  • 2. What is an Event-Driven Software Architecture? Event-Driven Software Architecture ● Consists of event producers, event consumers, and channels. ● Suitable for large distributed systems ● Decouples event producers from the event consumers. ● Components: ● Event: change in state meaningful to business ● Event Message: data about the event ● Producer: publisher of the event message over channel ● Channel: conduit to transmit the event ● Consumer: subscribes to a channel to receive event.
  • 3. Custom Platform Events ● Platform events are messages that are published and subscribed to. ● One or more subscribers can listen to the same event and carry out independent actions. ● This way, key components of an integration are decoupled. ● Define a custom event in same way as custom objects. ● Create the event by giving it a name and adding custom fields.
  • 4. Publishing Platform Events ● You can publish platform events by: ● Apex code. ● Point and click tools such as Process Builder and Flow Builder. ● Any Salesforce API from external applications. ● SOAP, REST or Bulk API Platform Event External App Salesforce Trigger REST API APEX
  • 5. Apex Published Events ● To publish event messages by Apex, call the EventBus.publish() method passing an instance of the custom event.
  • 6. Process Builder Published Events ● Add a Create a Record action. ● For the Record Type, select the custom platform event. ● Populate the fields of the platform event.
  • 7. API Published Events ● External applications use an API to publish event messages. ● You can use any Salesforce API to create events in same way as you would insert sObjects. ● To publish multiple event messages use the composite resource. REST endpoint: /services/data/v47.0/sobjects/Registration_Notification__e Request body: { "CaseId__c":"5008A000006GvpKQAS" } REST response: { "id" : "e01xx0000000001AAA", "success" : true, "errors" : [ { "statusCode" : "OPERATION_ENQUEUED", "message" : "154dba26-db92-4557-ad6b-9c7222428346", "fields" : [ ] } ] }
  • 8. Subscribing to Platform Events ● You can subscribe to platform events by: ● Apex Triggers. ● Point and click tools such as Process Builder and Flow Builder. ● Lightning apps can subscribe through the empApi component. ● Through CometD in external apps. Platform Event CometD Apex Trigger Process/Flow
  • 9. Subscribing to Events with Apex Triggers ● Triggers provide an auto subscription mechanism in Apex. No need to explicitly create and listen to a channel. ● Platform events ONLY support after insert triggers.
  • 10. Subscribing to Events with Processes ● Processes also provide an auto subscription mechanism for published events. No need to explicitly create and listen to a channel. ● To subscribe to a platform event, build the process to start when it receives an event message. ● Then associate the process with a platform event and an object
  • 11. Subscribing to Events with Lightning Components ● Subscribe to platform events with empApi component ● In Lightning Web components import the methods from the lightning/empApi module and then call the imported methods from your javascript code. ● In Aura components add the lightning:empApi component in your markup and then add functions to call the component methods in your client- side controller. Lightning Web Component: Import { subscribe, unsubscribe, onError, } from ‘lightning/empApi’; Lightning Aura Component: <lightning:empApi aura:id=“empApi” />
  • 12. Subscribing to Events with CometD ● External systems can subscribe to platform events using CometD ● The entities that consume platform events should subscribe to the event’s channel. The platform event for our example: /event/Registration_Notification__e Event message when received: { "data": { "schema":"dffQ2QLzDNHqwB8_sHMxdA", "payload": { "CreatedDate": "2020-03-09T18:31:40.517Z", "CreatedById": "005D0000001cSZs", "CaseId__c":"5008A000006GvpKQAS" }, "event": { "replayId": 1 } }, "channel": "/event/Registration_Notification__e“ }
  • 13. Automatic Retry Capabilities When Errors Occur ● Helpful to retry consuming an event when a transient error occurs. ● This is only available with event triggers. ● Retry events by throwing the EventBus.RetryableException.
  • 14. Resuming a Platform Event ● If a trigger stops execution intentionally or because of unhandled exception ● Set a checkpoint to resume by setting replay ID of last successful event message. ● EventBus.TriggerContext.currentContext().setResumeCheckpoint(event.replayId)
  • 15. Business Need – Organization Registration Notification Salesforce is integrated with JIRA to allow for synchronization of JIRA tickets with the corresponding Salesforce cases. Organizations register with Availity daily. Some of those registrations are flagged for follow up for additional information and a JIRA ticket is created along with a corresponding Salesforce case. Our Fraud Analysts, working in JIRA, identify the necessary information needed and apply a series of labels to the JIRA ticket and update the ticket status to Awaiting Reply. The Salesforce case is automatically updated with this information. The client support organization then manually reviews those labels and sends an email to the customer by concatenating a series of Lightning Email Templates that correspond to the labels assigned to the case. There are dozens of these registrations daily that often pile up for processing. The Goal is to remove the manual process of sending the notifications to customers.
  • 16. Apex Class Solution – Organization Registration Notification Platform Event Process Publishes Event JIRA Ticket Salesforce Case Apex Trigger REST API Trigger Subscribes to Event
  • 18. What’s Next? How can I learn more about Platform Events? Platform Events Developer Guide https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_intro.htm Platform Events Basics https://trailhead.salesforce.com/en/content/learn/modules/platform_events_basics

Notas del editor

  1. In 2017 Salesforce introduced platform events to support the Event-Driven software architecture Prior to this integrating distributed systems required tightly coupled point to point integrations such as the request response REST API integrations. Systems in request-response communication models make a request to a web service. In comparison, systems in an event-driven architecture react to an event in near real time when the event occurs. Event producers don’t know the consumers that receive the events. Any number of consumers can receive and react to the same events. The only dependency between producers and consumers is the semantic of the message content. Example: eCommerce system publishes a single event that is consumed by several services to handle (payment processing, shipping, inventory updates, …).
  2. Event similar to sObject -> Event message similar to how a record is an instance of a sObject. Note the API name suffix of __e instead of __c Published events cannot be edited/deleted. To consume the event, an app can subscribe to it (as opposed to querying it). Custom fields become the content or semantics of the event message. Publish Behavior: Publish After Commit. When subscriber dependent on data to be present or if you simply don’t want an event to publish if transaction fails. Publish Immediately. Without fear of rollback. This is especially convenient for logging purposes so that you don’t have to relay on debug logs.
  3. Not following best practices here for brevity In this example I want to publish the event when the case JIRA Status is changed to Awaiting Reply Populating and instantiating the same platform event we saw earlier. EventBus.publish() method pushes the message to the channel. Behavior is similar to Database.insert() where you can interrogate the Database.SaveResult. Apex governor limits apply. Each EvenBus.publish execution counts as a DML statement. You can also capture the Database.SaveResult object to determine whether the operation was successful or not in same fashion as you would insert or update sObjects.
  4. For Flows, add a Create Records element to the appropriate flow. Where you'd usually pick an object to create, select the custom platform event.
  5. Such as SOAP API, REST API, or Bulk API. POST request to the endpoint Request body will contain a JSON formatted message containing values for any of the fields defined for the event.
  6. We’ll look at some examples of subscribing by trigger and process and talk a little about the lightning components BUT we won’t explicitly go over CometD
  7. Not following best practices here for brevity Very similar to trigger for any sObject The after insert trigger event corresponds to the time after a platform event is published Along with processes, it is the most straight forward method of consuming published events Trigger Batch size: The Apex trigger batch size for platform events is 2,000 as opposed to trigger batch size of 200 for standard/custom objects.
  8. Build the process to start when it receives a platform event message. In the process’s trigger, associate the process with a platform event and an object. The object you choose determines with object fields you can access throughout your process. The process looks for a case record whose Id matches the case id in the event message. Flow Builder subscribes to events by using a Pause element instead of starting of flow when a platform event occurs. When the event is receives the flow resumes.
  9. Using empApi component is slightly different for Lightning Web Components versus Aura Components but both involve defining the empApi component and utilizing the empApi components methods of subscribe, unsubscribe, etc.
  10. Visualforce pages can use CometD as well. CometD is a scalable WebSocket and HTTP based event and message routing bus. CometD is a set of library to write web applications that perform messaging over the web. The replay ID is a system generated value, and it is used to position the event in the event stream.
  11. Great for situations where the error is likely to go away later. Could be timeouts, row locks. Or as simple as a field value change. Events are resent after a small delay that increases in subsequent retries. Retrying the event causes all events in the batch to be resent. May retry events 9 times (the initial run plus 9 retries). Make sure to retry LESS THAN 9 times. After the ninth retry, the trigger moves to an error state and must then be fixed and saved.
  12. Unhandled exceptions such as CPU or heap size limits. Intentionally designing trigger batch size limits or some other processing logic. Because trigger batch sizes can be 2000 instead of normal 200, you can reach some limits more readily. New batch starts with event message after the one with replay ID you set.
  13. Lightning Email Templates are not available for use in Email Alerts, so basic Process Builder or Workflow Rules are not an option. Additionally, there are dozens of these labels with the corresponding email templates which complicates the logic needed to implement with Process Builder or Workflow Rule. Since the label values match the email template names, I can query the needed email templates through Apex and send the notification to the customer.