Home  >  Blog  >   Salesforce

Salesforce Platform Events

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.

Rating: 4.7
  
 
1384
  1. Share:
Salesforce Articles

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.

Table of Content: Salesforce Platform Events

What are Salesforce Platform Events?

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.

Examples of Salesforce Platform Events

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.

Salesforce Platform to External Application

  • External Application to the Salesforce Platform

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.

    • It may alert a sales representative to process the customer’s request.
    • It may enable sending a confirmation email to the customer. 

External Application to the Salesforce Platform

  •  Salesforce Platform to 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.

Salesforce Platform to Salesforce Platform

Related Article: Salesforce Tutorial

What is Event-driven Salesforce Architecture?

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.

Event-drive Salesforce Architecture

Essentially, this architecture simplifies communication in large distributed systems. One of the reasons is that this architecture decouples publishers as well as subscribers.

Components of Event-driven Systems

In event-driven systems, many significant components play a vital role in exchanging real-time data between publishers as well as subscribers.

Components of Event-Driven Architecture

Let’s have a brief look at the components below:

  • Event

An event is created when there is a meaningful change in the state of a business process.

  • Event Message

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.

  • Event Producer aka Publisher

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.

  • Event Channel

It is a stream of events that flows from publishers to subscribers.  

  • Event Bus

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.

  • Event Consumer aka Subscriber

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.

MindMajix Youtube Channel

What is Publishing in Salesforce Platform Events?

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:

  • Declarative
  • Programmatic

Know that process builder and flows are used to publish events declaratively. On the other hand, Apex is used to publish events programmatically.

Publishing in Salesforce Platform Events

Let’s have a look ahead.

  • Flows

You can publish event messages to subscribers through workflows. Here, you need to create record elements to publish event messages.

  •  Processes

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.

  • Apex

You can also use Apex to publish messages from a salesforce application. By calling EventBus.publish method, the event messages are published.

  • Salesforce APIs

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

Pub/Sub API can publish event messages from external applications.

What is Subscribing in Salesforce Platform Events?

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.

  • Flows

You can use flows in addition to ‘called interviews’ to receive platform event messages. Also, they support an auto-subscription mechanism.

  • Processes

The processes built inside the process builder can receive event messages through APIs, Apex, and other processes. They also support an auto-subscription mechanism.

  • Apex Triggers

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.

  • Pub/Sub API

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.

  • CometD

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.

Types of Salesforce Platform Events

Generally, there are three types of Salesforce platform events. Let’s discuss them one by one below.

Types of Salesforce Platform Events

  •   Custom Platform Events

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.

  • Standard Platform Events

They are the salesforce platform events that have pre-defined fields. The following are the types of standard platform events.

    • Change data capture 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.

    • Standard platform event object list

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.

  • High-volume Platform 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.

Difference between sObjects and Salesforce Platform Events

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.

What do you mean by limits in Salesforce Platform Events?

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.

Advantages of Salesforce Platform Events

Let’s uncover the advantages of using salesforce platform events for effective communication. Here is the list:

  • With salesforce platform events, you can make scalable, secure, and reliable notifications or messages
  • You can encrypt event messages to enhance security
  • You can accelerate business processes by adapting salesforce platform events
  • Platform events encourage point-to-point integrations
  • They simplify communication without writing any hard logic
  • More than one client can listen to the same event and respond.
  • Above all, you can set permissions for creating salesforce platform events.

Conclusion

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.

Join our newsletter
inbox

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
NameDates
Salesforce TrainingFeb 27 to Mar 13View Details
Salesforce TrainingMar 02 to Mar 17View Details
Salesforce TrainingMar 05 to Mar 20View Details
Salesforce TrainingMar 09 to Mar 24View Details
Last updated: 04 Apr 2023
About Author

 

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 .

read more
Recommended Courses

1 / 15