All about Platform Events
Platform Events are used to deliver secure, scalable, and customizable notification within Salesforce or external app. Platform Event is based on Event-Driven Architecture. This is built in real time integration patterns in the Salesforce Platform which helps to reduce point-to-point integration.
Publishing platform event:
We can publish the platform events in 3 ways:
- Publish Events Messaging using APEX.
- Publish Events Messaging using Declarative tools (Process Builder or Cloud Flow Designer Tool / Visual Work flow).
- Publish Events Messaging using Salesforce API from external app.
Not supported in Platform event:
- The allOrNoneHeader API header is ignored when you publish platform events through the API.
- The Apex setSavepoint() and rollback() Database methods aren’t supported with platform events.
Subscription in Platform Event:
- Apex triggers receive event notifications.
- write an “after insert” Apex trigger on the event object to subscribe to incoming events.
- Triggers receive event notifications from various sources—whether they’re published through Apex or APIs.
- Visualforce and Lightning component apps receive events through CometD.
- CometD is a scalable HTTP-based event routing bus that uses an AJAX push technology pattern known as Comet.
- In an external app, you subscribe to events using CometD as well.
Defining Objects and fields in Platform Events:
Platform events can be created just like the custom objects. The biggest difference between Platform events and Custom object is suffix name for the api name. In Platform events, its api name suffix with __e where the custom object appends __c suffix to create api name. Unlike with custom objects, we cannot update or delete event record, or view event records in Salesforce User Interface.
Platform Events support only following custom fields type,
- Checkbox
- Date
- Data/Time
- Number
- Text
- Text Area (Long)