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?
- Efficient, high-throughput event streaming to/from external systems.
- Modern replacement for the legacy CometD-based Streaming API for subscribers.
- Publish events from an external system into Salesforce (and subscribe back).
- Clients in many languages (Python, Java, Node, C++, Go, etc.).
Key Characteristics
| Aspect | Detail |
|---|
| Protocol | gRPC, HTTP/2 |
| Payload | Binary, Apache Avro (compact vs JSON) |
| Direction | Both - Publish and Subscribe |
| Event types | Platform Events, Change Data Capture, Real-Time Event Monitoring |
| Flow control | Client requests a specific number of events based on its processing speed |
| Replay | ReplayId to resume from a stored position (within retention window) |
Pub/Sub vs CometD (Streaming API)
| Pub/Sub API | CometD / Streaming API |
|---|
| Transport | gRPC / HTTP/2 | Long polling (Bayeux) |
| Payload | Binary (Avro) | JSON |
| Flow control | Yes (pull-based) | No |
| Direction | Publish + Subscribe | Subscribe only |
Documentation
- Pub/Sub API - Get Started
- Pub/Sub API - Overview