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 under 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.

To download and build the EMP connector project:

  1. To download the project files, do one of the following.
    1. Clone the EMP-Connector project using git.
      1git clone https://github.com/forcedotcom/EMP-Connector
    2. 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.
After you build the project, a JAR file is generated that includes the connector and the LoginExample functionality. The JAR file is a shaded JAR—it contains all the 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, as follows.
1java -jar emp-connector-1.0.0-phat.jar <username> <password> <topic> [optional_replayId]

In this walkthrough, you run the connector example directly from the Java class in the Eclipse IDE and you provide the arguments in the IDE. Instead of running the provided examples, you can download the JAR file and write your own code that calls the EMP connector functions. To figure out how to write your client, check the examples given in the project under the /src/main/java/com/salesforce/emp/connector/example folder.

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