Newer Version Available

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

Subscribe with 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 LoginExample 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. Use the command appropriate for the environment against which you want to run EMP Connector.
    1. To run EMP Connector against your production org, type this command and supply your Salesforce login credentials and the channel to subscribe to. In this example, the channel is /data/ChangeEvents.
    2. To run EMP Connector against a specific instance, such as your sandbox instance, specify the login URL as a parameter and use the DevLoginExample class. For example, the login URL for sandbox is https://test.salesforce.com.