Skip to content

Event-Driven Architecture

Event-driven architecture (EDA) decouples systems by communicating through events rather than direct API calls. Salesforce provides multiple event technologies, and choosing the right one is a common CTA differentiator between candidates who pass and those who fail.


Why Event-Driven?

Traditional request-response integration creates tight coupling: System A must know about System B, handle its failures, and wait for its response. Event-driven architecture breaks that dependency.

AspectRequest-ResponseEvent-Driven
CouplingTight - caller knows calleeLoose - publisher does not know subscribers
AvailabilityCaller blocked if callee is downPublisher unaffected by subscriber failures
ScalabilityLimited by slowest participantSubscribers scale independently
LatencySynchronous waitAsynchronous processing
ComplexitySimple for 1:1Simple for 1:many
Error handlingDirect (caller gets error)Indirect (needs monitoring, DLQ)

Salesforce Event Technologies Comparison

FeaturePlatform EventsChange Data CaptureStreaming API (PushTopic)Pub/Sub API
PurposeCustom business eventsData change notificationsSOQL-based change notificationsHigh-throughput event streaming
Event definitionCustom (you define schema)Automatic (mirrors object fields)SOQL querySubscribes to PE/CDC channels
Publish mechanismApex, Flow, API, Process Builder (deprecated)Automatic on record changeAutomatic on record changegRPC publish
Subscribe mechanismApex Trigger, PE-Triggered Flow, API, LWCApex Trigger, API, LWCCometD clientgRPC subscribe
Retention72 hours (high-volume) / 24 hours (standard)3 daysNo replay storageDepends on event type
ReplayYes (replay ID)Yes (replay ID)LimitedYes (managed subscriptions)
DeliveryAt-least-onceAt-least-onceAt-most-onceAt-least-once
StatusActive, strategicActive, strategicMaintenance modeActive, strategic
CTA relevanceHighHighLow (legacy)High

Platform Events

Custom-defined events representing business occurrences. You control the schema (fields) and the semantics (what the event means).

When to Use

  • Custom business events not tied to a single record change (e.g., OrderSubmitted, PaymentProcessed)
  • Decoupling Salesforce from external systems
  • Broadcasting events to multiple subscribers
  • Triggering flows or processes from external systems

Architecture

Apex, Flow, and external API calls publish to a Platform Event channel; Apex triggers, PE-triggered flows, LWC, and external subscribers consume from it.
Figure 1. Platform Events support multiple publisher types and fan out to multiple independent subscribers. Publishing is independent of the DML transaction by default; use the “Publish After Commit” setting to tie event delivery to transaction success.

Key Characteristics

  • Standard volume: 25 events per Apex transaction, 24-hour retention
  • High volume: Unlimited publish from Apex, 72-hour retention (requires enablement)
  • Publish behavior: EventBus.publish() is independent of the DML transaction. Events publish even if the transaction rolls back (unless using setSavepoint() with platform events)
  • Subscribe in Apex: after insert trigger on the event object

Transaction independence

Platform Events publish independently of the DML transaction by default. If you publish an event and then the transaction rolls back, the event is STILL published. Use the Publish After Commit behavior setting on the event definition to tie publishing to transaction success. This is a critical CTA detail.

Standard vs High-Volume Platform Events

Standard-volume deprecation

Standard-volume platform events can no longer be created as of 2025. Existing standard-volume events continue to function, but full retirement is scheduled for Summer ‘27. All new platform event definitions should use high-volume. Plan migration of existing standard-volume events before the retirement date.

FeatureStandard Volume (deprecated)High Volume
Publish limit per transaction25No Apex limit
Retention24 hours72 hours
AllocationIncluded in orgRequires entitlement
ReplayYesYes
StatusNo new creation; retirement Summer ‘27Active, strategic
Use caseLegacy low-volume business eventsAll new platform event implementations

Change Data Capture (CDC)

Automatically publishes events when records are created, updated, deleted, or undeleted. No custom event definition needed. CDC mirrors the object’s fields.

When to Use

  • Synchronizing Salesforce data changes to external systems
  • Audit trails for data changes
  • Populating data lakes or warehouses in near-real-time
  • When you need to know WHAT changed (field-level change tracking)

Architecture

Any record DML operation triggers the CDC engine to automatically publish a change event to subscribers via Apex trigger or external Pub/Sub API.
Figure 2. CDC requires zero publish code. The engine automatically fires on any DML operation and includes field-level change tracking in the payload. The 3-day retention window allows subscribers to replay missed events after short outages.

CDC Event Payload

CDC events carry rich change information:

FieldDescription
ChangeEventHeaderChange type (CREATE/UPDATE/DELETE/UNDELETE), changed fields, record IDs
changedFieldsList of field API names that changed
Record fieldsCurrent values of changed fields
commitTimestampWhen the change was committed
transactionKeyGroups changes from the same transaction

Key Characteristics

  • Retention: 3 days
  • Objects: Standard and custom objects (select which to enable)
  • Enriched events: Includes which fields changed and their new values
  • Gap events: Published when CDC detects missed events, prompting subscribers to refresh
  • Composite changes: Multiple record changes in one transaction are grouped

CDC vs Platform Events

Decision FactorUse CDCUse Platform Events
Need to track data changesYes - automaticNo - you would have to build it
Custom event semanticsNo - tied to object schemaYes - you define the meaning
Field-level change trackingBuilt-in (changedFields)Must include manually
Multiple objectsEnable per objectOne event definition per use case
External publishingNo (Salesforce only)Yes (API, external systems)

CDC vs Platform Events: Side-by-Side Architecture

CDC and Platform Events flow through different paths on the same underlying event bus infrastructure.

CDC channels trigger automatically from DML with structured change payloads; Platform Event channels require explicit publish and carry custom schema fields.
Figure 3. CDC and Platform Events share the same event bus but serve different purposes: CDC for automatic data-change notifications with field-level tracking, Platform Events for custom business semantics with developer-controlled payloads. High-volume CDC on many objects can consume shared delivery allocations.

They share the same event bus infrastructure

Platform Events and CDC share event bus infrastructure. Delivery allocations are edition-dependent — consult the official Platform Event Allocations documentation for current numbers. In scenarios with high-volume CDC enabled on many objects, budget the shared allocation carefully. A common CTA trap: enabling CDC on too many objects and starving Platform Event delivery.


Pub/Sub API (gRPC)

The modern event streaming API replacing the CometD-based Streaming API. Built on gRPC for high-performance bidirectional streaming.

When to Use

  • External systems subscribing to high volumes of Platform Events or CDC
  • When you need managed subscriptions (server-side cursor tracking)
  • When CometD performance is insufficient
  • Modern microservices architectures using gRPC

Key Advantages Over Legacy Streaming

FeatureStreaming API (CometD)Pub/Sub API (gRPC)
ProtocolHTTP long-pollinggRPC (HTTP/2)
PerformanceModerateHigh throughput
Subscription managementClient-managedServer-managed (optional)
EncodingJSONAvro (compact binary)
BidirectionalSubscribe onlyPublish and subscribe
FutureMaintenance modeStrategic direction

Managed Subscriptions

Pub/Sub API supports managed subscriptions where the server tracks the subscriber’s position (replay cursor). If the subscriber disconnects and reconnects, it resumes from where it left off. The client does not need to store replay IDs.

External system subscribes with a managed subscription; the server tracks cursor position so reconnection resumes from the last committed checkpoint.
Figure 4. Managed subscriptions eliminate client-side replay ID management. The server tracks position and resumes from the last committed cursor on reconnect. This simplifies subscriber code and prevents event gaps after brief disconnections.

Pub/Sub API gRPC Bidirectional Streaming

The gRPC protocol enables full bidirectional streaming over a single HTTP/2 connection. Client and server operate independently, sending and receiving messages at the same time without blocking. This is fundamentally different from REST polling.

A persistent HTTP/2 connection supports simultaneous pull-based subscribe with cursor commits and publish flows with Avro-encoded events on one connection.
Figure 5. The gRPC protocol multiplexes subscribe and publish flows over a single persistent HTTP/2 connection. Pull-based delivery gives the client back-pressure control, and Avro binary encoding reduces payload size by 7-10x compared to JSON.
gRPC FeatureBenefit for Integration
HTTP/2 multiplexingMultiple streams over single connection, no connection overhead
Binary Avro encoding7-10x smaller payloads than JSON, lower bandwidth
Server-side cursorNo client-side replay ID management, simpler code
Pull-based deliveryClient controls pace; back-pressure built in
Bidirectional streamsPublish and subscribe on same connection

CTA board point

When recommending Pub/Sub API over CometD/Streaming API, highlight three things: (1) gRPC is 7-10x faster than REST/CometD, (2) managed subscriptions eliminate client-side replay ID management, and (3) Avro binary encoding reduces payload size significantly. CometD is in maintenance mode - all new implementations should use Pub/Sub API.


Event Bus Architecture

All Salesforce event technologies share the same underlying event bus infrastructure.

Shows all event producer types feeding Platform Event, CDC, and custom channels, with all consumer types including Apex, Flow, LWC, CometD, and gRPC subscribers.
Figure 6. All Salesforce event technologies share the same underlying event bus. DML operations feed CDC channels automatically; Platform Event channels require explicit publish calls. New implementations should use gRPC (Pub/Sub API) for external subscribers rather than legacy CometD.

Replay Mechanism and Retention

Events are stored temporarily on the event bus with a replay ID. Subscribers replay missed events within the retention window.

Event TypeRetention PeriodReplay Support
Platform Events (standard volume)24 hoursYes (replay ID)
Platform Events (high volume)72 hoursYes (replay ID)
Change Data Capture3 daysYes (replay ID)
Generic Streaming (legacy)NoneNo

Replay Positions

PositionBehavior
-1 (LATEST)Only receive new events from now
-2 (EARLIEST)Replay all events from beginning of retention window
Specific replay IDResume from a specific point

The 24-hour/72-hour trap

If your subscriber is down longer than the retention period, those events are gone. Always design for this: What is the recovery strategy when the subscriber misses events beyond the retention window? Options: full data reconciliation job, alerting when subscriber lag exceeds a threshold, or a hybrid approach combining CDC with periodic batch sync.


Event-Driven Decision Flowchart

Routes event-driven integration needs through trigger type, field-change requirements, throughput, and subscriber type to CDC, Platform Events, or Pub/Sub API.
Figure 7. Event technology selection depends on what triggers the event, whether field-level change tracking is needed, and the subscriber’s performance requirements. External high-throughput subscribers should always use Pub/Sub API gRPC rather than the legacy CometD protocol.

Outbound Messages vs Platform Events

Both Outbound Messages and Platform Events deliver asynchronous notifications from Salesforce to external systems, but they use very different architectures. Picking the wrong one creates unnecessary complexity or limits scalability.

Comparison

FactorOutbound MessagesPlatform Events
ProtocolSOAP (WSDL-based)REST, gRPC (Pub/Sub API), CometD
TriggerWorkflow Rules (end of support Dec 2025) or Flow actionsApex, Flow, REST API, external gRPC publish
Delivery modelPush to a specific SOAP endpointPub/Sub - publish to bus, subscribers pull
RetryBuilt-in: retries for 24 hours (extendable to 7 days) until positive ACKAt-least-once delivery; no automatic endpoint retry (subscriber manages replay)
IdempotencyUnique message ID preserved across retriesReplay ID for subscriber-side deduplication
Subscriber countSingle endpoint per outbound messageMultiple independent subscribers
PayloadUp to 100 field values from the triggering record + Session IDCustom schema you define (any fields)
RetentionQueued until ACK or expiry (24h/7d)72 hours (high-volume) / 24 hours (standard)
VolumeLow-moderate (queued delivery)High (high-volume PE: no Apex transaction limit)
StatusActive but legacy-adjacentStrategic, actively enhanced

Decision Guide

ScenarioRecommendationRationale
Simple notification to a single SOAP endpointOutbound MessageBuilt-in retry, zero code, WSDL contract
Multiple subscribers need the same eventPlatform EventsPub/Sub model supports multiple independent subscribers
High-volume or burst notificationsPlatform EventsHigh-volume PE has no per-transaction publish limit
External system publishes events into SalesforcePlatform EventsOutbound Messages are Salesforce-to-external only
Need to include custom/computed data in the payloadPlatform EventsOutbound Messages are limited to record field values
Legacy SOAP integration with existing WSDL consumerOutbound MessageAvoids rework if consumer already handles the WSDL
Event-driven architecture with replay and monitoringPlatform EventsReplay IDs, Pub/Sub API managed subscriptions, event monitoring

CTA Exam Relevance

The board sometimes presents a scenario where an admin configured Outbound Messages for a notification pattern that now needs to scale to multiple consumers or higher volume. The correct answer is to migrate to Platform Events, but acknowledge the trade-off: you lose built-in endpoint retry (the subscriber must manage replay/redelivery) and must build idempotent consumers. When the scenario describes a simple, single-endpoint SOAP notification with no scaling concerns, Outbound Messages remain a valid and simpler choice.


Anti-Patterns

Anti-PatternWhy It FailsBetter Approach
Using events for guaranteed deliveryAt-least-once is not exactly-onceDesign idempotent consumers, add reconciliation
Ignoring replay windowEvents lost after retention expiresMonitor subscriber lag, batch sync fallback
Polling instead of subscribingWastes API calls, higher latencySubscribe via Pub/Sub API or CDC
Publishing events on transaction rollbackCreates phantom eventsUse “Publish After Commit” behavior
Single subscriber bottleneckOne slow subscriber blocks processingScale subscribers independently, use DLQ

  • Data Quality & Governance: CDC event subscribers must handle data quality issues (missing fields, invalid formats) gracefully
  • Modern Platform Features: Platform Events and CDC are foundational to Agentforce, Flow orchestration, and modern event-driven platform capabilities
  • Sharing Model: event subscribers run in system context; sharing rules still apply to data accessed by event handlers

Sources

Personal study notes for the Salesforce CTA exam. Content compiled from VJ's study notes, official Salesforce documentation, community sources, and online publicly available content, then organized and presented with AI assistance. Not affiliated with Salesforce. © 2025–2026 VJ Srivastava.