Newer Version Available

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

Step 3: Download and Build the Project

Before you can run the connector examples, download the Java source files and build the Java project.

Prerequisites:

The EMP Connector project includes examples in the GitHub repository’s example folder that use the connector to log in and subscribe to events. In the next steps, you run the following examples locally on your system.

LoginExample.java logs in to your production instance. To pass in a custom login URL, such as for sandbox or My Domain, use DevLoginExample.java instead. DevLoginExample.java also provides debug logging for the Bayeux messages received.

Note

To download and build the EMP connector project:

  1. To download the project files, do one of the following.
    • Clone the EMP-Connector project using git.
      1git clone https://github.com/forcedotcom/EMP-Connector
    • Download the project zip file from GitHub, and then extract the zip to a local folder.
  2. In Eclipse, import the Maven project from the folder where you cloned or extracted the project.
    The dependencies that are specified in the Maven’s pom.xml file, such as CometD, are added in the Java project in Eclipse.
  3. If the Java project wasn’t automatically built, build it.

If you prefer to run the tool from the command line, generate the JAR file using the Maven command mvn clean package. The generated JAR file includes the connector and the LoginExample functionality. The JAR file is a shaded JAR—it contains all dependencies for the connector, so you don’t have to download them separately. The JAR file has a -phat Maven classifier. You can run the login example from the command line. This command uses the LoginExample class by default, which logs in to your production instance.

1java -jar target/emp-connector-0.0.1-SNAPSHOT-phat.jar <username> <password> <channel> [optional_replayId]

To pass in a custom login URL, such as for sandbox or My Domain, use the DevLoginExample class. For example, for sandbox, specify https://test.salesforce.com for <login_URL>.

1$ java -classpath target/emp-connector-0.0.1-SNAPSHOT-phat.jar com.salesforce.emp.connector.example.DevLoginExample <login_URL> <username> <password> <channel> [optional_replayId]

Note

Open Source Project

EMP Connector is an open-source project, so you can contribute to it with your own enhancements by submitting pull requests to the repository.