Salesforce Streaming API is used when integration required with publisher and subscriber model. This slide will explain about
1. Streaming Event
2. PushTopic
3. Generic Event
4. Comparison of Streaming Events
2. SalesforceCodex.com 2
About Me
Dhanik Lal Sahni
Technical Architect
Conduent Business Solution
Certified Application Architect
Twitter : @dhaniksahni
Blog : salesforcecodex.com
3. SalesforceCodex.com 3
Session 11-Agenda
• In a given scenario, recommend when to use API-based
integrations, such as SOAP, REST, Bulk, Streaming, Canvas,
Workflow outbound, APEX (Callouts, @ future, etc.), and
Lightning Connect to achieve business requirements.
• Compare and contrast the advantages and drawbacks (design
trade-offs) of using API-based integrations such as SOAP, REST,
Bulk, Streaming, Canvas, Workflow outbound, APEX (Callouts,
@future, etc.), and Lightning Connect.
28%
17%
15%
10%
15%
10%
5%
Integration Architecture
Designer Exam
1 2 3 4 5 6 7
Salesforce Integration Capabilities:: 28%
4. SalesforceCodex.com 4
AGENDA
• What is Streaming Event?
• Push vs Pull Technology
• Short Vs Long Polling
• Overview of Push Topic
• Overview of Generic Events
• Streaming Events Comparison
• Use Cases
5. SalesforceCodex.com 5
Streaming API
• Streaming API enables transmitting of real time data from Salesforce Platform
• Transmission of data done using push technology
• Push technology transfers information that is initiated from a server to the client.
• Provides a subscription mechanism for receiving events in near real time.
• Push technology also called the publish/subscribe model
Push Topic
Generic Event Platform Event
Change Data Capture
L
e
g
a
c
y
C
u
r
r
e
n
t
7. SalesforceCodex.com 7
STREAMING EVENT TECHNOLOGY
Pull Technology
Push Technology • Notifications are sent to the subscriber in real time.
• No pooling required.
• Clients request data from the server periodically.
• Clients poll the server for data updates, and freshness of data depends on the
poll frequency.
• Clients can make excessive calls and cause server slowdown.
8. SalesforceCodex.com 8
MECHANISM OF STREAMING API
Short Polling
Long Polling
• Clients send requests for information but with the expectation the server may
not respond immediately.
• Server respond when data is changed for object
• Long polling supported using Bayeux Protocol or CometD
• Client keeps sending request to make active connection
• To enable Publisher/Subscriber model, active connection is required between Salesforce and each client
9. SalesforceCodex.com 9
PUSH TOPIC
PushTopic events provide a secure and scalable way to receive
notifications for changes to Salesforce data that match a SOQL query
you define.
Use PushTopic events to:
Receive notifications of Salesforce record changes, including create, update, delete, and undelete
operations.
Capture changes for the fields and records that match a SOQL query.
Receive change notifications for only the records a user has access to based on sharing
rules.
10. SalesforceCodex.com 10
PUSH TOPIC
Create PushTopic PushTopic Name
PushTopic inserted
in database
Notification
condition/event
• All
• Referenced(default)
• Select
• Where
SOQL Query
11. SalesforceCodex.com 11
PUSH TOPIC SECURITY
• To receive notification user must have access to object
• Field Level Access required
• Only record where user has access will be returned
12. SalesforceCodex.com 12
Considerations - Multiple Notifications in Same Transaction
Streaming API Notifications
Sent in Reverse Order Within a
Transaction
• In general, event notifications are delivered in the order of record changes.
• When a record triggers multiple notifications within the same transaction, the
last notifications are delivered first.
Multiple Streaming API
Notifications for the Same
Record and Untracked Fields
If field change triggers other field changes on the same record, more
notifications are sent for those fields.
Only Last PushTopic
Notification Sent for the Same
Record
When multiple PushTopic notifications are generated for the same record within
about one millisecond and in the same transaction, only the last notification is
sent.
13. SalesforceCodex.com 13
PushTopic Streaming Allocation
Description Performance and
Unlimited Editions
Enterprise
Edition
All other supported
editions
Maximum number of topics (PushTopic records) per org 100 50 40
Maximum number of concurrent clients (subscribers)
across all channels and for all event types
2,000 1,000 20
Maximum number of delivered event notifications within
a 24-hour period, shared by all CometD clients
1,000,000 200,000 50,000 (10,000 for
free orgs)
Socket timeout during connection (CometD session) 110 seconds 110 seconds 110 seconds
Timeout to reconnect after successful connection
(keepalive)
40 seconds 40 seconds 40 seconds
Maximum length of the SOQL query in the Query field of
a PushTopic record
1,300 characters 1,300 characters 1,300 characters
Maximum length for a PushTopic name 25 characters 25 characters 25 char
14. SalesforceCodex.com 14
GENERIC EVENTS
Use generic events to send custom notifications that are not tied to
Salesforce data changes.
Use Generic Events to:
Publish and receive arbitrary payloads in JSON without a predefined event schema
Broadcast notifications to a target set of users, specific teams, or your entire org
Send notifications for events that are external to Salesforce
15. SalesforceCodex.com 15
HOW TO USE GENERIC EVENTS
1. A StreamingChannel that defines the channel, with a name that is case-sensitive
2. It is object and can be accessed from app menusStreaming Channel
Clients
Streaming Channel
Push REST API
One or more clients subscribed to the channel
Streaming Channel Push REST API to monitor and invoke push events on the
channel
16. SalesforceCodex.com 16
USE CASE -1
Robert is developing a custom app for a client, which is used by the
client’s service reps and displays a feed of case records from
Salesforce
Requirement:
• The feed stays up-to-date and displays the latest changes from Salesforce without the
need for reps to click the Refresh button.
• If a new case is assigned to a rep, the case is added to the feed.
• If the status or subject of a case is changed, the data is refreshed in the case feed.
• If a case is escalated, a red exclamation point is added to the case in the feed.
Stream Events to use : PushTopic
17. SalesforceCodex.com 17
USE CASE -2
Robert’s client wants a custom app that lets its users place orders for
parts.
Requirement:
• When a user places an order through the Salesforce app, the app notifies the external
parts supplier service.
• When the supplier ships the parts order, the Salesforce app is notified, posts a message
in Chatter, and updates a case.
Stream Events to use : Platform events
18. SalesforceCodex.com 18
USE CASE -3
Robert wants to develop an app for service reps that display
notification messages that the service rep manager sends from a
console app in Salesforce.
Example:
Robert’s manager can send notifications to specific reps about important events, such as
system maintenance announcements or warnings of a rep’s low number of resolved cases.
Stream Events to use : Generic Events
19. SalesforceCodex.com 19
USE CASE -4
Robert’s client wants an integration that synchronizes Salesforce
record data changes with their HR system, which is external to
Salesforce.
Example:
1. Every new or changed Employee__c record is replicated in the HR data store.
2. All Employee__c records are replicated along with their fields.
3. The replication is transaction-based. If multiple updates are in a single transaction, the
integration app sends these updates as part of one transaction as well.
4. If the data replication process fails, it’s possible to resume the replication from past event
notifications that are stored for up to three days.
Stream Events to use : Change Data Capture