Newer Version Available

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

Subscribe with CometD Using the EMP Connector Sample

Salesforce provides a connector to CometD that subscribes to streaming events. The EMP connector sample is a thin wrapper around the CometD library and simplifies subscribing to data change events in Java. The tool subscribes to a channel, receives notifications, and supports replaying events with durable streaming.

EMP Connector is a free, open-source, community-supported tool. Salesforce provides this tool as an example of how to subscribe to events using CometD. To contribute to the EMP Connector project with your own enhancements, submit pull requests to the repository at https://github.com/forcedotcom/EMP-Connector.

Important

Prerequisites:

Steps:

  1. To get a local copy of the EMP-Connector GitHub repository:
  2. To build the EMP-Connector tool, enter these commands:
    The generated JAR file includes the connector and the DevLoginExample functionality. The shaded JAR contains all the dependencies for the connector, so you don’t have to download them separately. The JAR file has a -phat Maven classifier.
  3. Run this command.

    For a sandbox, replace https://MyDomainName.my.salesforce.com with https://MyDomainName--SandboxName.sandbox.my.salesforce.com.

    If you’re not using enhanced domains, your sandbox My Domain URLs are different. You can find your org’s My Domain login URL on the My Domain Setup page.

    Note

    For <channel>, use the channel to subscribe to. For example, /data/ChangeEvents.