Newer Version Available

This content describes an older version of this product. View Latest

Compose Streams of Change Data Capture Notifications with Custom Channels

Subscribe to a custom channel to receive a stream of the types of events that your app consumes. For example, if you have an app that uses real-time information about sales objects (for example, Account, Contact, and Order), create a custom channel with these objects. When you subscribe to the custom channel, you receive notifications only for these objects.

You can create a custom channel with Metadata API. You can also package channels to distribute with your apps.

You can’t create or view custom channels in Setup in the Change Data Capture page.

Note

Create a Custom Channel with Metadata API

Use the PlatformEventChannel metadata type to create and retrieve a custom channel.

This example of a custom channel called SalesEvents includes event names for related sales objects: Account, Contact, and Order.

1<?xml version="1.0" encoding="UTF-8"?>
2<PlatformEventChannel xmlns="http://soap.sforce.com/2006/04/metadata">
3     <label>Custom Channel for Sales Events</label>
4    <channelMembers>
5        <selectedEntity>AccountChangeEvent</selectedEntity>
6    </channelMembers>
7    <channelMembers>
8        <selectedEntity>ContactChangeEvent</selectedEntity>
9    </channelMembers>
10    <channelMembers>
11        <selectedEntity>OrderChangeEvent</selectedEntity>
12    </channelMembers>
13    <channelType>data</channelType>
14</PlatformEventChannel>

This package.xml references the previous definition.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <members>SalesEvents__chn</members>
5        <name>PlatformEventChannel</name>
6    </types>
7    <version>46.0</version>
8</Package>

For more information, see PlatformEventChannel in the Metadata API Developer Guide.