14

Salesforce offers two variants of the Streaming API - PushTopic and Generic.

In Summer '17 (v40.0) Platform Events are now also Generally Available (GA).

How do they differ and why would you use one over the other?

  • This is the best read I've seen on the difference between Streaming Events (look at the chart towards the bottom of the post) – Brian Miller Feb 12 at 14:48
12

Very generally, the Streaming API was created primarily to update UI components(Source) where as Platform Events are for integrations via a Message Bus.

With a PushTopic from the Streaming API you are limited to receiving events notifications when the configured query and event occur. There is no capacity to manually generate these events beyond causing the criteria required by the query and event.

Generic Streaming via the Streaming API is similar to Push Topics but is not bound to specific changes to Salesforce data. Instead you control when to publish an event. The trade off is that the payload of the event is a 3000 character string rather than a defined structure like that of a PushTopic.

Platform Events provide the defined notification structure of a PushTopic with a more flexible model than Generic Streaming for raising and subscribing to the events. They can be published and subscribed to via Apex in addition to the APIs.


As Mohith commented, there are differences with the limits between Platform Events and the Streaming API.

E.g.

  • Maximum number of topics (PushTopic records) per org
    UE: 100 EE: 50 All other editions: 40
  • Maximum streaming channels per org
    UE: 1,000 EE: 1,000 PE: 1,000 Free: 200
  • Maximum number of platform event definitions that can be created in an org
    UE: 100 EE: 50 All other editions: 5

Another interesting difference is that PushTopics are limited to 2,000 clients/subscribers across all topics for Unlimited Edition orgs. Where as for the Generic Streaming that limit is 2,000 clients/subscribers per generic streaming channel. Platform events don't currently have a documented limit on subscribers.


From What Is the Difference Between the Salesforce Events?

Platform Events

Platform events enable you to deliver secure, scalable, and customizable event notifications within Salesforce or from external sources. Platform event fields are defined in Salesforce and determine the data that you send and receive. Apps can publish and subscribe to platform events on the Force.com Platform using Apex or in external systems using CometD.

Streaming API Events

Streaming API provides two types of events that you can publish and subscribe to: PushTopic and generic. PushTopic events track field changes in Salesforce records and are tied to Salesforce records. Generic events contain arbitrary payloads. Both event types don’t provide the level of granular customization that platform events offer. You can send a custom payload with a generic event, but you can’t define the data as fields. You can’t define those types of events in Salesforce, and you can’t use them in Apex triggers.

  • 3
    The platform events have greater limits than streaming .The No of push topics are limited for an org .Platform Events seems to have lot more run way in terms of limits . – Mohith Shrivastava May 30 '17 at 2:58
  • @MohithShrivastava Good point. I've added some details about the limits. – Daniel Ballinger May 30 '17 at 8:44
10

Another significant differences -

  • In streaming API's we lose the update (event) if the subscriber is offline, however in platform events they will be available in the event bus for a duration of 24 hours. So if a subscriber comes online after sometime, he will still have access to updates happened during outage time.

    [Update] Same can be achieved for streaming APIs using Durable push topics.

  • Platform events are a first class object, that means you can setup multiple fields and can have your own structure to publish events. It wasn't possible on streaming APIs, as you had to rely on object fields which can be part of query.

  • Streaming APIs push updates were managed by the system, however Platform events needs to be fired manually. It will add additional responsibility to manage scenarios for platform events, where SF transaction failed but event has been pushed to Event bus.
  • 2
    For the 24 hour duration. My understanding is that the same applies to the Streaming API. Via Message Durability. So a subscriber could potentially catch up with events within the last 24 hours. – Daniel Ballinger May 30 '17 at 2:01
  • umm interesting. Thanks for adding that @DanielBallinger – Salesforcesmarty May 30 '17 at 2:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.