Filter Your Stream of Change Events with Channels
Receive only the change event messages that match a predefined filter on a channel in subscribers. With fewer events delivered to subscribers, event processing is optimized. Also, subscribers make more efficient use of the event delivery allocation. This feature supports Pub/Sub API, CometD (Streaming API), and event relays but not Apex triggers.
If you use Government Cloud and your org was created before January 14, 2022, contact Salesforce to enable this feature. Government Cloud orgs created on or after January 14, 2022 have this feature enabled. This feature is available in all other clouds.
-
Filter a stream of change events by adding a filter expression on a channel member. A filter expression can contain Salesforce entity fields and event header fields, which are part of ChangeEventHeader. A change data capture channel can have one or more channel members, and each channel member can have its own filter.
-
Filter Expressions in Channel Members
Add a filter expression in a channel member that’s associated with a custom or the standard ChangeEvents channel. We recommend that you use a custom channel so that the filtered stream is isolated from the standard event stream and subscribers expect the stream to be filtered. The channel holds the filtered stream of events that match the filter expression for the specified change event.
-
Subscribe to the Channel and Receive the Filtered Event Stream
After configuring the filter, subscribe to the channel, and receive the event messages that match the filter expression. The channel to subscribe to is
/data/ChannelName__chn. Only Pub/Sub API and CometD clients support stream filtering. Because Apex triggers don’t support channels, you can’t use them to subscribe to filtered event streams. -
Get Custom Channels and Channel Members
You can find which channels and channel members are set up in your Salesforce org by performing SOQL queries through Tooling API.
See Also