Enterprise Messaging Platform

Messaging includes a new feature, Platform Events, that is generally available.
Available in: Performance, Unlimited, Enterprise, and Developer Editions

Deliver Custom Notifications with Platform Events (Generally Available)

Monitor your systems and communicate changes with platform events. Has your order system shipped a package? Do your printer cartridges need replacing? Whatever you want to be notified about, Salesforce’s enterprise messaging platform provides the delivery of secure and scalable custom notifications within Salesforce and from external sources. This change applies to both Lightning Experience and Salesforce Classic.

Platform events are part of Salesforce’s enterprise messaging platform. The platform provides an event-driven messaging architecture to enable apps to communicate inside and outside of Salesforce. Custom data in your events are stored in custom fields that you define. Platform events simplify the process of communicating changes and responding to them without writing complex logic. Publishers and subscribers communicate with each other through events. Multiple subscribers can listen to the same event and carry out different actions.

By using platform events, publishers can send customized event data through Apex or an API. Subscribers can receive custom notifications from Salesforce or an external system using Apex or CometD clients. Based on the event’s contents, subscribers can process custom business logic, such as sending an email or logging a case. For example, a software system monitoring a printer can make an API call to publish an event when the ink is low. The printer event can contain custom fields for the printer model, serial number, and ink level. The event is processed in Salesforce by an Apex trigger that places an order for a new cartridge.

Define Your Platform Event

Define your platform event on the Platform Events page in the Salesforce user interface. From Setup, enter Platform Events in the Quick Find box, then select Platform Events. Create a platform event definition by giving it a name and adding custom fields. The custom fields define the data that is sent in the event messages. Platform events support a subset of field types in Salesforce.

For example, this table lists a definition of custom fields for a printer ink event.

Field Name Field API Name Field Type
Printer Model Printer_Model__c Text
Serial Number Serial_Number__c Text
Ink Percentage Ink_Percentage__c Number
Manufacturing Date Manufacturing_Date__c Date

A platform event is a special kind of sObject. An event notification is an instance of the platform event, similar to how a record is an instance of a custom object. Unlike custom objects, you can’t view event records in the Salesforce user interface, and platform events don’t have page layouts. Platform events aren’t transactional and can’t be rolled back. Also, platform events are retained for 24 hours and CometD subscribers can retrieve past events using a unique ID (the ReplayId field value).

Platform Event Limits

Description Performance and Unlimited Editions Enterprise Edition All other supported editions
Maximum number of events published per hour

(Events can be published using Apex or APIs.)

100,000 100,000 1,000
Maximum event message size 5 MB
Maximum number of events delivered to CometD clients within a 24-hour period1 50,000 25,000 10,000
Maximum number of platform event definitions that can be created in an org 100 50 5

1To request a higher number of events delivered to CometD clients, contact Salesforce to purchase an add-on license. The add-on license increases your daily limit of delivered events by 100,000 more events. For example, for Unlimited Edition, the add-on license increases the daily limit of delivered events from 50,000 to 150,000 events. You can purchase multiple add-ons to meet your event requirements for CometD clients. To avoid deployment problems and degradation in service, we recommend that the number of events delivered to CometD clients not exceed 5 million per day. If you require additional external events, contact your Salesforce representative to understand how the product can scale to meet your needs.

Platform Event Changes in Summer ’17

In the last release, Platform Events was in beta. In this release, it is generally available, and we made the following improvements and changes.

Non-Transactional Events
Platform events are processed outside database transactions in the Force.com platform. As a result, they can’t be rolled back.
Limits
We made various limit changes, including the addition of an add-on license for increased event limits for CometD clients. See Platform Event Limits.
Databinding.ObjectMapper No Longer Supported
The Databinding.ObjectMapper class, along with its transform methods, has been removed. The utility methods were deprecated last release.

For more information, see the Platform Events Developer Guide.

Supported CometD Versions for Streaming API

Use CometD version 3.0.9 or later in your clients to connect to Streaming API. Earlier versions are no longer supported and could result in unexpected behavior. To prevent potential issues with old CometD versions in your clients, upgrade the CometD library to a supported version. For more information, see https://cometd.org/.
Note

Note

We upgraded the Visualforce code samples in the Streaming API Developer Guide to use version 3.1.0 of CometD.