Let’s walk through the steps to create a channel and add two platform events via channel members. Then, you can subscribe to the channel to validate receiving event messages for platform events.
-
Prerequisite: Define Platform Events
The custom channel examples depend on a predefined custom platform events called Order_NorthAmer__e and Order_EMEA__e. Before creating the custom channel, define these events in Salesforce.
-
Create a Custom Channel and Add Platform Events with Tooling API
Create a channel for orders named Order_Channel__chn, and add two platform events as members: Order_NorthAmer__e and Order_EMEA__e.
-
Metadata API Example: Create a Custom Channel and Add Platform Events
Instead of Tooling API, you can use Metadata API to create a channel and channel member. We recommend using Metadata API as part of the application lifecycle management process to develop, test, deploy, and release your apps to production. If you want to only configure the channel, we recommend using Tooling API with REST.
-
Subscribe to the Channel
After creating a custom channel and its members, subscribe to the channel using a Pub/Sub API Java client, and receive event messages.