Skip to main content

Table of Contents

Integration - Pub/Sub API

A single, efficient interface to publish and subscribe to the event bus - Platform Events, Change Data Capture, and Real-Time Event Monitoring events. Built on gRPC over HTTP/2, delivering binary messages in Apache Avro.

When to Use Pub/Sub API?

  1. Efficient, high-throughput event streaming to/from external systems.
  2. Modern replacement for the legacy CometD-based Streaming API for subscribers.
  3. Publish events from an external system into Salesforce (and subscribe back).
  4. Clients in many languages (Python, Java, Node, C++, Go, etc.).

Key Characteristics

AspectDetail
ProtocolgRPC, HTTP/2
PayloadBinary, Apache Avro (compact vs JSON)
DirectionBoth - Publish and Subscribe
Event typesPlatform Events, Change Data Capture, Real-Time Event Monitoring
Flow controlClient requests a specific number of events based on its processing speed
ReplayReplayId to resume from a stored position (within retention window)

Pub/Sub vs CometD (Streaming API)

Pub/Sub APICometD / Streaming API
TransportgRPC / HTTP/2Long polling (Bayeux)
PayloadBinary (Avro)JSON
Flow controlYes (pull-based)No
DirectionPublish + SubscribeSubscribe only

Documentation

  1. Pub/Sub API - Get Started
  2. Pub/Sub API - Overview