SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Integrating with salesforce using platform events
Integrating with salesforce using platform eventsIntegrating with salesforce using platform events
Integrating with salesforce using platform events
Amit Chaudhary
 
PlatForm Event.pptx
PlatForm Event.pptxPlatForm Event.pptx
PlatForm Event.pptx
Rinku Saini
 
Salesforce Streaming event - PushTopic and Generic Events
Salesforce Streaming event - PushTopic and Generic EventsSalesforce Streaming event - PushTopic and Generic Events
Salesforce Streaming event - PushTopic and Generic Events
Dhanik Sahni
 
Real Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform EventsReal Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform Events
Salesforce Developers
 
Salesforce Integration Pattern Overview
Salesforce Integration Pattern OverviewSalesforce Integration Pattern Overview
Salesforce Integration Pattern Overview
Dhanik Sahni
 
Salesforce Streaming Api
Salesforce Streaming ApiSalesforce Streaming Api
Salesforce Streaming Api
Jayant Jindal
 
Custom Metadata and Custom Settings and Custom Lebel in Salesforce.pptx
Custom Metadata and Custom Settings and Custom Lebel in Salesforce.pptxCustom Metadata and Custom Settings and Custom Lebel in Salesforce.pptx
Custom Metadata and Custom Settings and Custom Lebel in Salesforce.pptx
mohayyudin7826
 
Einstein analytics basics
Einstein analytics basicsEinstein analytics basics
Einstein analytics basics
Amit Chaudhary
 
Endless Use Cases with Salesforce Experience Cloud by Dar Veverka
Endless Use Cases with Salesforce Experience Cloud by Dar VeverkaEndless Use Cases with Salesforce Experience Cloud by Dar Veverka
Endless Use Cases with Salesforce Experience Cloud by Dar Veverka
Alesia Dvorkina
 
Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforce
Mark Adcock
 
Salesforce Einstein Analytics
Salesforce Einstein AnalyticsSalesforce Einstein Analytics
Salesforce Einstein Analytics
Harshala Shewale ☁
 
Salesforce admin training 1
Salesforce admin training 1Salesforce admin training 1
Salesforce admin training 1
HungPham381
 
Lightning web components
Lightning web components Lightning web components
Lightning web components
Cloud Analogy
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platform
John Stevenson
 
Salesforce Tableau CRM - Quick Overview
Salesforce Tableau CRM - Quick OverviewSalesforce Tableau CRM - Quick Overview
Salesforce Tableau CRM - Quick Overview
Harshala Shewale ☁
 
Salesforce Online Training
Salesforce Online TrainingSalesforce Online Training
Salesforce Online Training
Keylabs
 
Salesforce Community Cloud
Salesforce Community CloudSalesforce Community Cloud
Salesforce Community Cloud
Jayant Jindal
 
Introduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelIntroduction to the Salesforce Security Model
Introduction to the Salesforce Security Model
Salesforce Developers
 
Azure role based access control (rbac)
Azure role based access control (rbac)Azure role based access control (rbac)
Azure role based access control (rbac)
Srikanth Kappagantula
 
Power Platform Governance
Power Platform GovernancePower Platform Governance
Power Platform Governance
Daniel Laskewitz
 
Integrating with salesforce using platform events
Integrating with salesforce using platform eventsIntegrating with salesforce using platform events
Integrating with salesforce using platform events
Amit Chaudhary
 
PlatForm Event.pptx
PlatForm Event.pptxPlatForm Event.pptx
PlatForm Event.pptx
Rinku Saini
 
Salesforce Streaming event - PushTopic and Generic Events
Salesforce Streaming event - PushTopic and Generic EventsSalesforce Streaming event - PushTopic and Generic Events
Salesforce Streaming event - PushTopic and Generic Events
Dhanik Sahni
 
Real Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform EventsReal Time Integration with Salesforce Platform Events
Real Time Integration with Salesforce Platform Events
Salesforce Developers
 
Salesforce Integration Pattern Overview
Salesforce Integration Pattern OverviewSalesforce Integration Pattern Overview
Salesforce Integration Pattern Overview
Dhanik Sahni
 
Salesforce Streaming Api
Salesforce Streaming ApiSalesforce Streaming Api
Salesforce Streaming Api
Jayant Jindal
 
Custom Metadata and Custom Settings and Custom Lebel in Salesforce.pptx
Custom Metadata and Custom Settings and Custom Lebel in Salesforce.pptxCustom Metadata and Custom Settings and Custom Lebel in Salesforce.pptx
Custom Metadata and Custom Settings and Custom Lebel in Salesforce.pptx
mohayyudin7826
 
Einstein analytics basics
Einstein analytics basicsEinstein analytics basics
Einstein analytics basics
Amit Chaudhary
 
Endless Use Cases with Salesforce Experience Cloud by Dar Veverka
Endless Use Cases with Salesforce Experience Cloud by Dar VeverkaEndless Use Cases with Salesforce Experience Cloud by Dar Veverka
Endless Use Cases with Salesforce Experience Cloud by Dar Veverka
Alesia Dvorkina
 
Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforce
Mark Adcock
 
Salesforce admin training 1
Salesforce admin training 1Salesforce admin training 1
Salesforce admin training 1
HungPham381
 
Lightning web components
Lightning web components Lightning web components
Lightning web components
Cloud Analogy
 
Introducing the Salesforce platform
Introducing the Salesforce platformIntroducing the Salesforce platform
Introducing the Salesforce platform
John Stevenson
 
Salesforce Tableau CRM - Quick Overview
Salesforce Tableau CRM - Quick OverviewSalesforce Tableau CRM - Quick Overview
Salesforce Tableau CRM - Quick Overview
Harshala Shewale ☁
 
Salesforce Online Training
Salesforce Online TrainingSalesforce Online Training
Salesforce Online Training
Keylabs
 
Salesforce Community Cloud
Salesforce Community CloudSalesforce Community Cloud
Salesforce Community Cloud
Jayant Jindal
 
Introduction to the Salesforce Security Model
Introduction to the Salesforce Security ModelIntroduction to the Salesforce Security Model
Introduction to the Salesforce Security Model
Salesforce Developers
 
Azure role based access control (rbac)
Azure role based access control (rbac)Azure role based access control (rbac)
Azure role based access control (rbac)
Srikanth Kappagantula
 

Similar to 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
mohayyudin7826
 
Platform events
Platform eventsPlatform events
Platform events
arun jain
 
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 Processing
Miguel González
 
FIWARE Complex Event Processing
FIWARE Complex Event ProcessingFIWARE Complex Event Processing
FIWARE Complex Event Processing
Miguel García González
 
Event-Based API Patterns and Practices
Event-Based API Patterns and PracticesEvent-Based API Patterns and Practices
Event-Based API Patterns and Practices
LaunchAny
 
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
Stefan Weber
 
SAP workflow events
SAP workflow eventsSAP workflow events
SAP workflow events
Norikkon, LLC.
 
Extending WSO2 Analytics Platform
Extending WSO2 Analytics PlatformExtending WSO2 Analytics Platform
Extending WSO2 Analytics Platform
WSO2
 
[Webinar] Camunda Optimize Release 3.0
[Webinar] Camunda Optimize Release 3.0[Webinar] Camunda Optimize Release 3.0
[Webinar] Camunda Optimize Release 3.0
camunda services GmbH
 
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 Developers
 
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
Lucas 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 Events
John 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 India
Point Perfect Technology Solutions
 
Explore Event Driven Archtecture using PHP
Explore Event Driven Archtecture using PHPExplore Event Driven Archtecture using PHP
Explore Event Driven Archtecture using PHP
NexGismo
 
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
KadharBashaJ
 
Platform Events Demo (1).pptx
Platform Events Demo (1).pptxPlatform Events Demo (1).pptx
Platform Events Demo (1).pptx
DileepSingh682144
 
COM Events for Late-bound Delivery of Information
COM Events for Late-bound Delivery of InformationCOM Events for Late-bound Delivery of Information
COM Events for Late-bound Delivery of Information
Arun Seetharaman
 
Understanding Business APIs through statistics
Understanding Business APIs through statisticsUnderstanding Business APIs through statistics
Understanding Business APIs through statistics
WSO2
 
4.out port
4.out port4.out port
4.out port
JudePragashVedam
 
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
mohayyudin7826
 
Platform events
Platform eventsPlatform events
Platform events
arun jain
 
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 Processing
Miguel González
 
Event-Based API Patterns and Practices
Event-Based API Patterns and PracticesEvent-Based API Patterns and Practices
Event-Based API Patterns and Practices
LaunchAny
 
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
Stefan Weber
 
Extending WSO2 Analytics Platform
Extending WSO2 Analytics PlatformExtending WSO2 Analytics Platform
Extending WSO2 Analytics Platform
WSO2
 
[Webinar] Camunda Optimize Release 3.0
[Webinar] Camunda Optimize Release 3.0[Webinar] Camunda Optimize Release 3.0
[Webinar] Camunda Optimize Release 3.0
camunda services GmbH
 
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 Developers
 
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
Lucas 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 Events
John 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 India
Point Perfect Technology Solutions
 
Explore Event Driven Archtecture using PHP
Explore Event Driven Archtecture using PHPExplore Event Driven Archtecture using PHP
Explore Event Driven Archtecture using PHP
NexGismo
 
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
KadharBashaJ
 
Platform Events Demo (1).pptx
Platform Events Demo (1).pptxPlatform Events Demo (1).pptx
Platform Events Demo (1).pptx
DileepSingh682144
 
COM Events for Late-bound Delivery of Information
COM Events for Late-bound Delivery of InformationCOM Events for Late-bound Delivery of Information
COM Events for Late-bound Delivery of Information
Arun Seetharaman
 
Understanding Business APIs through statistics
Understanding Business APIs through statisticsUnderstanding Business APIs through statistics
Understanding Business APIs through statistics
WSO2
 
Ad

Recently uploaded (20)

F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
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
 
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
 
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
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
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
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
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
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
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
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
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
 
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
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
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
 
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
 
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
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
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
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
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
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
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
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Maxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINKMaxon CINEMA 4D 2025 Crack FREE Download LINK
Maxon CINEMA 4D 2025 Crack FREE Download LINK
younisnoman75
 
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
 
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
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Ad

Platform Events by Tim Taylor

  • 1. Platform Events Salesforce’s Event-Driven Software Architecture [email protected] 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

Editor's Notes

  • #3: 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, …).
  • #4: 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.
  • #6: 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.
  • #7: 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.
  • #8: 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.
  • #9: 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
  • #10: 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.
  • #11: 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.
  • #12: 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.
  • #13: 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.
  • #14: 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.
  • #15: 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.
  • #17: 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.