Newer Version Available
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.
Prerequisites:
- Git. See Git Downloads.
- Apache Maven. This example uses Apache Maven to build the EMP Connector project. Download and install it from the Apache Maven site.
- Java Development Kit 8 or later. See Java Downloads.
Steps:
-
To get a local copy of the EMP-Connector GitHub repository:
-
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.
-
Use the command appropriate for the environment against which you want to run EMP
Connector.
-
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.
-
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.
-
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.