How Salesforce Platform Events Power Event-Driven Architecture

How Salesforce Platform Events Power Event-Driven Architecture

Home > Blog > Salesforce
Thiago Terzi May 11, 2026

Share Now |

Modern systems demand more than simple data storage; they need to react instantly to changes. Event‑driven architecture delivers this responsiveness by broadcasting signals whenever something noteworthy happens. In the Salesforce ecosystem, Salesforce platform events provide this capability by enabling real‑time communication within Salesforce and between external systems. From my experience working on Salesforce integration projects, platform events help reduce tight system dependencies and make large integration landscapes easier to maintain and scale. Instead of polling for updates, systems listen for events and respond immediately. This article explains how to use this event-driven model effectively within Salesforce integrations and automation workflows.

What Are Salesforce Platform Events

A platform event in Salesforce is a custom message definition that allows your applications to communicate changes as they occur. When something significant happens, like a record update, a system operation, or an external trigger, you can publish an event message. This message travels over an event bus and notifies subscribers. The Salesforce platform events framework follows a publish‑subscribe model: producers create events, the event bus queues and orders them, and consumers receive notifications.

This architecture removes the need to constantly ask Salesforce if something has changed. Instead, event consumers subscribe once and wait for notifications. In many enterprise Salesforce consulting service engagements, platform events are used to reduce polling-based integrations and simplify real-time communication between systems. Platform events in Salesforce are built on the Streaming API, ensuring reliable delivery with replay capabilities. You define the event structure by creating a custom platform event object with fields that carry the necessary information, similar to a custom object.

Components of Salesforce Platform Events

Every platform event involves several roles. Producers publish events when something occurs. Publishers can be Apex code, flows, processes, or external applications calling REST or SOAP APIs. The event bus holds the event messages in order and ensures they are delivered. Consumers subscribe to events and react by executing logic or updating data. Event consumers can range from Apex triggers and Flow-based automation to external services listening through CometD or the Pub/Sub API.

Each event payload carries the custom fields configured as part of the platform event definition. A typical Salesforce platform event might include references to records, timestamps, status codes, or error descriptions. Defining a schema carefully ensures subscribers receive only the data needed to take action. Once an event is published, it stays in the event bus for 72 hours (for high‑volume events), allowing subscribers to replay missed messages if they were disconnected. This retention period makes real‑time processing reliable even during network interruptions.

Use Cases and Benefits of Platform Events

One of the most compelling reasons to use platform events in Salesforce is the ability to integrate with external systems in real time. Instead of relying on scheduled jobs or API polling, you can push a notification whenever something happens. For example, when a customer signs up for a webinar, you can publish an event that triggers registration in a marketing automation system. This reduces latency, improves user experience, and ensures data consistency across platforms. This pattern is commonly used in Shopify CRM integration strategies, where customer activity and order updates must move between systems in near real time.

System Decoupling

Another benefit is decoupling components. Event publishers and consumers work separately from one another, reducing tight connections between integrated systems. A publisher sends an event and moves on; the consumer subscribes and reacts when ready. This loose coupling makes your architecture more resilient and easier to maintain. When you replace or upgrade a consumer, you do not need to modify the producer, as long as the event schema remains compatible. This design enables teams to work independently without breaking integrations.

Simplified Orchestration

Complex processes often span multiple systems. Platform events simplify orchestrating these processes by broadcasting milestones. For example, consider an order workflow that includes inventory validation, payment processing, and shipment coordination. When an order is created, an event notifies all systems. Each system consumes the event and performs its tasks, then publishes its own events “inventory reserved,” “payment authorized,” “order shipped.” This orchestrated choreography keeps each service focused on its responsibility and reduces tight dependencies. The same event-driven orchestration model is frequently used in inventory visibility patterns in CRM environments where inventory, fulfillment, and CRM systems must remain synchronized continuously.

Internal Notifications and User Experience

Within Salesforce, platform events can drive user notifications and automated reactions. You can publish events from Apex or flow logic to trigger updates in Lightning components, refresh dashboards, or send notifications via flows. This improves user experience because relevant data appears instantly without manual refresh. This creates a more reactive user experience where screens and components update immediately as new data becomes available. 

Define and Publish Salesforce Platform Events

To get started, define a Salesforce platform event by navigating to Setup and selecting “platform events.” Choose a name, API name, and description. Then add custom fields just as you would for a custom object. Decide whether the event should be published after a database transaction is committed (publish after commit) or before. High‑volume platform events are the default and support millions of published events per day. You can also configure whether the event is replayable. Many modernization initiatives combine event-driven architecture with a structured data migration process in Salesforce to move historical records before real-time synchronization begins.

Publishing Events from Apex, Flows, and APIs

After defining the event, you can publish messages in multiple ways:

  • Apex: Use EventBus.publish() in Apex to send one or multiple events. In asynchronous operations or triggers, this method pushes your event into the event bus. You can handle errors by checking the publish status.
  • Flows and Process Builder: Create a platform event-triggered flow or process to publish an event when certain criteria are met. Flows are ideal for admin‑level configurations without coding. Processes can also publish events when records change.
  • REST and SOAP APIs: External systems can publish events by sending API calls. For example, you can call the /events/<EventName>_e endpoint to insert an event record. Bulk API can publish multiple events in a single request.

Because publishing events consumes resources, it counts toward both your API usage and your platform event publishing allocation. Always group events logically to minimize overhead. Efficient publishing reduces the risk of hitting limits.

Subscribing to Apex Platform Events

Once events are being published, subscribers need to react. In Salesforce, you can create an Apex trigger on the platform event object. The trigger runs every time an event is delivered and allows you to perform complex logic, like updating records or launching future calls. Apex triggers can handle high throughput because they do not count against event delivery limits. This makes Apex an excellent choice for internal handling of high‑volume events.

Flows and Process Builder can also subscribe to platform events. Create a “platform event-triggered flow,” then design your logic to run when an event arrives. This option empowers admins to build real‑time integrations without code. Flows can update records, create tasks, or invoke subflows based on event data.  This asynchronous processing pattern is commonly used in enterprise Salesforce integration architectures where multiple systems exchange operational updates in near real time. They are perfect for business processes that require point‑and‑click solutions.

Connect External Applications to Platform Events

External clients subscribe to events using the Pub/Sub API or CometD protocol. Each subscriber opens a streaming connection and listens for new messages. You can use Java, JavaScript, or any language that supports CometD. The Pub/Sub API provides an easy way to subscribe, acknowledge messages, and manage the replay cursor. When designing external subscriptions, ensure your client can handle network interruptions and replay missed events. Implementing reconnection logic is essential for reliability.

Replay and Durability

The event bus retains events for 72 hours (for high‑volume events). Each event has a replay ID. After reconnecting, a subscriber can use the last processed replay ID to retrieve any events that were not received during the disconnect period. It is important to store this replay ID in persistent storage. Reliable event handling ensures no data is lost during outages. For external clients, storing the replay ID in a database or file system allows the subscriber to resume exactly where it left off.

Platform Event Limits Salesforce and Considerations

When planning your implementation, you must respect limits. The platform event limits Salesforce imposes to ensure fair usage across customers. Several categories of limits exist:

  • Event Definitions: There are limits on the number of custom platform events you can define. In higher editions like Performance and Unlimited, you can create up to 100 event definitions; Enterprise allows 50; Developer and Professional with API Add‑On are limited to five. Platform events from managed packages count toward this total.
  • Concurrent Subscribers: Streaming clients connected via CometD, Pub/Sub API, and Lightning components consume a concurrent client allocation. Depending on your edition, you may have between 20 and 2,000 concurrent clients. Exceeding this limit prevents new subscribers from connecting until others disconnect.
  • Event Publishing Allocation: This is the number of events you can publish per hour. The default allocation is 250,000 events per hour in Performance, Unlimited, and Enterprise editions, and 50,000 events per hour in Developer Edition. Publishing events also consume API calls when using REST, SOAP, or Bulk API.
  • Event Delivery Allocation: This is the number of event messages that can be delivered to API‑based subscribers in a 24‑hour period. High‑volume events and Change Data Capture share this allocation. By default, Performance and Unlimited editions can deliver 50,000 events per day, Enterprise and Professional can deliver 25,000, and Developer Edition can deliver 10,000. Deliveries to Apex triggers, flows, and Process Builder do not count toward this limit.
  • Message Size: Each event message can be up to 1 MB. Keep your payloads as small as necessary to improve performance.
  • Subscribers per Channel: There are limits on how many platform events you can add to a single custom channel and how many channels you can create, often 50 events per channel and 100 custom channels. Real‑Time Event Monitoring events have separate limits.
  • Processes and Flows: There is a cap on how many platform events-triggered processes and flows you can have and how many can be active simultaneously. This ensures each org maintains good performance.

In large enterprise environments, event-driven architectures can also expose underlying record ownership and locking issues.

Exceeding these Salesforce platform events limits results in errors. If a publish call exceeds the publishing allocation, Salesforce returns a LIMIT_EXCEEDED exception. If the delivery allocation is exceeded, subscribers using CometD or Pub/Sub API receive errors and the connection is closed. Regularly track event usage and allocations to prevent unexpected limit issues.

Ways to Manage Platform Event Consumption and Quotas

To avoid hitting the Salesforce platform event limits, consider the following strategies:

  • Batch Events: Group multiple changes into a single event when possible. Instead of sending one event per record update, aggregate related changes into one event with an array or summary. This reduces publishing and delivery counts.
  • Filter Subscriptions: Only subscribe to the events you need. If multiple clients subscribe to a channel but do not need all messages, you waste deliveries. Use channel filtering to restrict event types delivered to each subscriber.
  • Leverage Apex Subscribers: Where possible, use Apex triggers or flows for on‑platform subscribers. Apex and flow deliveries do not count against the daily delivery quota, making them ideal for internal processing.
  • Monitor Consumption: Track publishing and delivery activity using platform event usage metric and related API endpoints. Configure notifications so administrators are warned before usage thresholds are exceeded.
  • Purchase Add‑Ons: If your integration requires more events than the default, you can purchase an event add‑on license to increase your quotas.

Best Practices for Designing and Using Platform Events

Spend time designing your event schema. Include only the fields that subscribers need. Avoid large payloads; keep event messages concise. Document each field clearly so that new consumers can understand and use the event effectively.

Ensure Idempotency

Subscribers should handle events idempotently. Because a Salesforce platform events message might be delivered more than once or delivered out of order, subscribers must be able to recognise if an event has already been processed. Use unique identifiers or timestamps, and store processed IDs to avoid duplicating work. Idempotent design protects your data integrity.

Handle Ordering Considerations

Event order is guaranteed within partitions but not across multiple partitions. In practice, a subscriber might receive events slightly out of sequence if multiple publishers produce events at the same time. Do not rely on strict order; instead, design your logic to handle events individually. If order matters, include sequence numbers in the event payload. This approach gives your consumers enough context to handle events properly.

Build Proper Failure Handling Logic

Subscribers must handle errors gracefully. Apex triggers should include error handling logic and avoid unhandled exceptions that block future deliveries. External subscribers should implement retry logic and back‑off strategies when encountering network issues. Robust error handling prevents event processing from grinding to a halt.

Use Replay IDs and Persistence

Always persist the last replay ID processed by a subscriber. If the connection drops, your client can reconnect from the last known replay ID and avoid missing events. High‑volume events store messages for 72 hours, giving you a generous window to replay. Storing the replay ID in a durable location, like a database or file system ensures reliable recovery.

Protect Platform Event Access and Communication

Platform events inherit Salesforce security. Only authenticated users and integrations can publish and subscribe. Ensure that your integration users have only the permissions they need. Use named credentials and secure remote site settings when connecting external subscribers. Applying proper security controls helps prevent unauthorized access and reduces the risk of misuse across event-driven integrations. Similar governance considerations also appear in Salesforce SharePoint integration projects where authentication, file permissions, and API communication require strict control models.

Regularly Validate and Monitor Event Processing

Before deploying to production, test your events in a sandbox. Simulate high volumes and multiple subscribers to ensure your design scales. Once live, monitor usage metrics and logs regularly. As your architecture evolves, revisit your events to retire unused ones and refine schemas. Continuous improvement keeps your event‑driven architecture healthy. Event-driven architectures benefit from a documented sandbox strategy Salesforce teams can use to test Platform Events, CDC, and integration resiliency before release.

Summary

Salesforce platform events support real-time communication patterns that help systems exchange updates efficiently without creating tightly connected integrations. By creating a platform event in Salesforce, you define a message that encapsulates a significant change or action. Producers publish events to the event bus, and subscribers consume them without the need for constant polling. This model simplifies integrations and improves performance.

In this article, I have explained what Salesforce platform events are and why they are essential. You learned about event components, use cases, publishing and subscribing methods, and how to work within the platform event limits. You also discovered best practices such as designing clear schemas, ensuring idempotency, planning for order and error handling, and monitoring usage. By following these guidelines, you can modernise your integrations and deliver real‑time experiences across Salesforce and beyond.

Recent Posts

Salesforce Integration Tools: Middleware, iPaaS, and Connector Guide
August 28, 2026
8 Best Tips for Efficient Account Management in Salesforce
August 28, 2026
Salesforce Data Integration: Strategy, Mapping, and Synchronization Guide
August 25, 2026
Jira Salesforce Integration: Complete Planning and Setup Guide
August 18, 2026

Request a Free 30-Minute Salesforce Consultation

Whether it’s implementation, integration, or custom development—let’s discuss the right solution for your organization.

    Thiago T

    Senior Salesforce Consultant - Co-Founder @ dgt27

    Thiago is a highly skilled full-stack Salesforce developer with over 10 years of experience. He has successfully implemented Salesforce solutions for clients from various walks of life. His expertise extends across different sectors, including government, non-profit organizations, large and small companies, as well as universities. Thiago's diverse experience allows him to tailor Salesforce solutions to meet the unique needs and challenges of clients in different industries. Currently, he leads a team of 10x certified Salesforce developers across the US, Europe, and South Asia.

    Leave Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Was this blog helpful?

    Was this blog helpful?