Publishing & Subscribing to Platform Events
- johnsontitus
- May 19, 2020
- 1 min read
Lightning component uses empApi component to subscribe and receive event messages.
External clients can subscribe to events using CometD.
A custom CometD client can be implemented or Emp Connector can be used.
Platform events are sent by Salesforce to CometD clients sequentially in the order they are received.
Use case:
Events could be published from a Heroku application (via the REST API) or from a trigger on Chatter posts (via Apex). They should be received by a Lightning console app that should act as a subscriber (via the lightning:empApi component that uses a CometD client connection).
Solution Design:

For implementation details refer to https://github.com/JohnsonTitus/auraPubSubEvent.git
Use case:
When a sales order is created on an external web application, Salesforce user has to be notified and custom object record should be created.
Solution:
Using platform event, the external web app can publish it by using one of Salesforce's API - SOAP or REST or Bulk API.
Salesforce can subscribe to it using trigger on platform event object or process builder.

Comments