Salesforce platform events is one of the robust messaging platforms used for businesses. Know that Salesforce platform events work based on the publisher-subscriber model. Whenever there is a change in the state of a business process, an event is created. Event messages are broadcasted to applications inside the salesforce platform and external ones. All right! Are you interested to learn more about salesforce platform events? Through this blog, we put forward the primary mechanism of salesforce platform events and a lot along the road.
Undeniably, communication is no less than any other business process. It must be fast, secure, and reliable to sustain a business in today’s fast-moving world. That’s why businesses are always interested in adapting efficient communication mechanisms.
This way, salesforce platform events is one of the robust messaging platforms that support broadcasting messages to applications. They transport messages inside the salesforce platform applications as well as with external applications.
Well! The ultimate goal of this blog is to make you understand salesforce platform events, types, examples of salesforce platform events, and many more.
Salesforce platform events are nothing but one of the powerful messaging platforms used in businesses. The Salesforce platform events work based on an event-driven messaging architecture. This architecture supports communicating real-time information between applications inside the salesforce platform. Not only that, it supports salesforce applications to communicate with external applications. In short, salesforce platform events support communication within the salesforce platform and with external systems.
Essentially, Salesforce platform events connect publishers with subscribers. When the events are created, they send messages or notifications to subscribers. It is essential to note that salesforce platform events are created when there are changes in the state of business processes. No wonder any number of subscribers can receive messages from a single publisher.
Mainly, you can simplify communication between applications without writing any hard logic.
To understand salesforce platform events better, consider this example. Suppose the ink level in a printer cartridge runs down to a low level. It creates an event in the salesforce platform. It triggers the order processing application in the salesforce platform. After that, the event message, along with the cartridge details, is sent to all its subscribers. The right subscriber that can process this order starts shipping a new cartridge.
If you want to enrich your career and become a professional in Salesforce Database, then enroll in "Salesforce Online Training". This course will help you to achieve excellence in this domain. |
As you know, the Salesforce platform events induce communication between publishers as well as subscribers. It can be done in three modes as follows:
Want to know how?
Let’s take a look at them in with examples.
Salesforce Platform to External Application
Consider you have got a new order from one of your customers. It creates an event in the salesforce platform. This is because the arrival of the new order changes the state of the business process, which in turn induces the event. Once the event is created, the publisher sends an event message along with the order details to all its subscribers. The subscribers can be vendor applications. The correct vendor application that can process this new order accepts it, sends confirmation, and process the order further.
Consider a customer who wants to return a purchased product. The request of the customer to return the product creates an event through an external application. The event listener receives this event in the salesforce platform. It triggers the following events in the salesforce platform.
Consider there is a new sales lead in the salesforce platform. Consequently, a lead trigger in the Salesforce platform creates an event. Once the event is triggered, Salesforce verifies the opportunities with the lead owner. Based on the verification results, Salesforce may reassign the lead.
Related Article: Salesforce Tutorial |
Event-driven architecture is also known as message-driven architecture. This architecture consists of event producers aka publishers, event consumers aka subscribers, and channels. This architecture works based on the publisher-subscriber model. It means there is no request-response mechanism and no role of any server to manage communication between publishers and subscribers.
Essentially, this architecture simplifies communication in large distributed systems. One of the reasons is that this architecture decouples publishers as well as subscribers.
In event-driven systems, many significant components play a vital role in exchanging real-time data between publishers as well as subscribers.
Let’s have a brief look at the components below:
An event is created when there is a meaningful change in the state of a business process.
Generally, an event message consists of information about the event. For example, if raising a purchase order is an event, the event message will have all the details required for processing a purchase order.
Know that publishers broadcast event messages to their subscribers. Event messages are broadcasted to subscribers in the same order they are received from publishers.
An event producer is nothing but the publisher of an event message. In other words, the event producer creates an event and publishes it. For example, you can consider an order placing application as an event producer.
It is a stream of events that flows from publishers to subscribers.
It is the transportation medium that carries event messages from publishers to subscribers. Event bus usually operates in the queue mode in chronological order. In simple words, it executes events one by one.
It is the destination system or application that receives event messages. Once the events are put across the event bus, subscribers will be immediately notified.
For example, a vendor application can be a subscriber. It can receive event messages from a publisher that may be an order-processing application.
Once salesforce platform events are created, they publish event messages through flows, Apex, processes, etc.
Salesforce platform events can be published in two ways as follows:
Know that process builder and flows are used to publish events declaratively. On the other hand, Apex is used to publish events programmatically.
Let’s have a look ahead.
You can publish event messages to subscribers through workflows. Here, you need to create record elements to publish event messages.
In this case, a process builder is used to publish event messages from a Salesforce application. And you need to create a record action with respect to processes.
You can also use Apex to publish messages from a salesforce application. By calling EventBus.publish method, the event messages are published.
External applications can publish messages using APIs. To create events, you can use salesforce APIs such as SOAP API, Bulk API, or REST API. The APIs usually reply with messages to publishers about whether the delivery is a success or failure.
Pub/Sub API can publish event messages from external applications.
Similar to publishing events, you can subscribe to events with flows, Apex triggers, processes, Pub/Sub API, etc. And it can be done declaratively as well as programmatically.
Flows are used to subscribe to events declaratively. And Apex, Workbench, and LWC are used to subscribe to events programmatically.
You can use flows in addition to ‘called interviews’ to receive platform event messages. Also, they support an auto-subscription mechanism.
The processes built inside the process builder can receive event messages through APIs, Apex, and other processes. They also support an auto-subscription mechanism.
You can use Apex triggers to subscribe to event messages. By writing an ‘after insert apex’ trigger on an event object, subscriptions to incoming events are achieved. Triggers also support an auto-subscription mechanism.
You can use Pub/Sub API to receive event messages in external systems or applications. You can publish, retrieve, subscribe, and the event schema with a single API. Using this API, you can control the volume of event messages received.
You can use cometD to subscribe to Salesforce platform events in an external client. You can use a cometD client or EMP connector, typically an open-source tool, to listen to a channel.
Generally, there are three types of Salesforce platform events. Let’s discuss them one by one below.
In a way, custom platform events are sObjects like custom objects. They support publishing and processing custom notifications. Remember the ink cartridge example mentioned earlier? It is one of the examples of custom platform events.
No doubt we can define salesforce platform events like we define custom objects. We can create a custom platform event by giving it a name along with adding custom fields. Not only that, we can add more fields if we want to do so.
We can publish custom events on the lightning platform using Apex, flow builder, process builder, or an API in external applications. We can subscribe to custom events like we do for publishing.
They are the salesforce platform events that have pre-defined fields. The following are the types of standard platform events.
It is one of the standard events that publish events when there is a change in the salesforce records. The changes can be creating, deleting, or updating records.
It is yet another standard event that is published to report errors. Or, if there is any update in the user login activities, this event is published.
For example, BatchApexErrorEvent reports errors in batch apex jobs. LoginEventStream tracks user login activities. Also, AssetTokenEvent tracks the authentication activities in the salesforce platform.
It is essential to note that event messages are sent to all the systems subscribed to these events.
These events can publish and process a massive volume of events. No wonder millions of events can be processed at a time. They provide better scalability than other types. Mainly, high-volume events take time to be published. Only when the publishing call returns successfully will the publish request be processed in Salesforce.
In many ways, salesforce objects and platform events go parallel though they differ in a few cases. For example, an event in the salesforce platform is like a record in an instance of a salesforce object. But you cannot update or delete events like events. Not just that, you cannot view the events in User Interface.
There are limits in delivering events, including event delivery in cometD clients.
Wondering what it means? Let’s read further.
Essentially, the ‘event delivery limit’ refers to delivering the maximum number of notifications to its subscribers within 24 hours. Salesforce allows publishing a maximum of 10 k events per hour. Also, you can publish a maximum of 50 k events within 24 hours.
Apart from the above, only 2 k concurrent clients can subscribe to salesforce platform events simultaneously. If you want to subscribe to more clients, you can combine Salesforce with external applications such as Heroku. So, you can use salesforce platform events for B2C applications too. Besides, you can purchase add-ons if you want to increase the limits.
Let’s uncover the advantages of using salesforce platform events for effective communication. Here is the list:
In a nutshell, Salesforce Platform events are a reliable and robust method for implementing B2C communication. They broadcast event messages when there is any change in the state of the business processes. It allows exchanging information, both internal and external, to the salesforce platform. The main thing about salesforce platform events is that you can broadcast messages without hard logic. Undoubtedly, salesforce platform events boost the productivity of businesses through its effective messaging mechanism.
Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
Name | Dates | |
---|---|---|
Salesforce Training | Nov 19 to Dec 04 | View Details |
Salesforce Training | Nov 23 to Dec 08 | View Details |
Salesforce Training | Nov 26 to Dec 11 | View Details |
Salesforce Training | Nov 30 to Dec 15 | View Details |
Madhuri is a Senior Content Creator at MindMajix. She has written about a range of different topics on various technologies, which include, Splunk, Tensorflow, Selenium, and CEH. She spends most of her time researching on technology, and startups. Connect with her via LinkedIn and Twitter .
What are Salesforce Platform Events?
Examples of Salesforce Platform Events
What is Event-driven Salesforce Architecture?
Components of Event-driven Systems
What is publishing Salesforce Platform Events?
What is Subscribing Salesforce Platform Events?
Types of Salesforce Platform Events
Difference between Salesforce Objects and Salesforce Platform Events