Event-Driven Architecture in Salesforce

Share

What Is Event-Driven Architecture?

Short Description

Event-driven architecture means systems react to events instead of constantly checking for changes.

Simple Explanation

Instead of asking “Did something change?”,
the system says “Something changed—here’s the update.”


Real-Life Example

  • Online order placed → Warehouse notified → Delivery started
    No system waits or polls—events trigger actions.


Gist (Quick Revision)

Event-driven systems respond automatically when something happens.


1. Platform Events

What Are Platform Events?

Platform Events are custom events used to publish and subscribe messages inside Salesforce or with external systems.

Simple Explanation

Platform Events are like announcements over a speaker—any listener can react.


When to Use Platform Events

  • Notify multiple systems

  • Decouple systems

  • Real-time communication


Platform Event Example

Event Definition (Example Fields)

  • OrderId

  • Status


Publishing a Platform Event

Order_Status_Event__e event = new Order_Status_Event__e(
    OrderId__c = 'ORD-001',
    Status__c = 'Shipped'
);
EventBus.publish(event);

Subscribing to a Platform Event

trigger OrderStatusTrigger on Order_Status_Event__e (after insert) {
    for (Order_Status_Event__e evt : Trigger.new) {
        System.debug('Order Status: ' + evt.Status__c);
    }
}

Gist (Quick Revision)

Platform Events allow Salesforce to broadcast messages that other systems can react to.


2. Change Data Capture (CDC)

What Is Change Data Capture?

CDC tracks data changes (insert, update, delete, undelete) on Salesforce records and publishes them as events.

Simple Explanation

CDC tells you what changed, when it changed, and how it changed.


Real-Life Example

A customer updates their phone number →
All connected systems are instantly informed.


What CDC Captures

  • Record ID

  • Changed fields

  • Change type (create/update/delete)


CDC Example (Conceptual)

trigger AccountChangeTrigger on AccountChangeEvent (after insert) {
    for (AccountChangeEvent evt : Trigger.new) {
        System.debug('Account changed: ' + evt.ChangeType);
    }
}

Why CDC Is Powerful

  • No custom code needed to detect changes

  • Near real-time sync

  • Ideal for integrations


Gist (Quick Revision)

CDC automatically publishes record changes as events.


3. Event-Based Integrations

What Are Event-Based Integrations?

Event-based integrations use events instead of APIs to connect systems.

Simple Explanation

APIs ask for data.
Events push data automatically.


Real-Life Example

  • Salesforce updates order status

  • ERP, Billing, and Notification systems all react instantly


Why Event-Based Integrations Are Better

  • Loose coupling

  • Better scalability

  • Faster response

  • Fewer API calls


Platform Events vs CDC (Easy Comparison)

Platform Events CDC
Custom business events Data change events
Manually published Automatically published
Flexible payload Standard structure

Gist (Quick Revision)

Event-based integrations push updates in real time without polling.

  • January 6, 2026