Newer Version Available
Build and Run EMP Connector on the Command Line
Before you can run the EMP connector example, build the Java files.
-
Get EMP Connector from GitHub.
1$ git clone https://github.com/forcedotcom/EMP-Connector.git -
Build the EMP Connector tool.
1$ cd EMP-Connector 2$ mvn clean packageThe generated JAR file includes the connector and the DevLoginExample functionality. The shaded JAR contains all the dependencies for the connector, so downloading them separately isn’t necessary. The JAR file has a -phat Maven classifier. -
Subscribe to either a platform event or a custom channel. In this example, you subscribe to
the Low_Ink__e platform event. Run this command after replacing the placeholder values.
For <login_URL>, use one of these values.
- My Domain login URL, including the https:// prefix: https://MyDomainName.my.salesforce.com
- For sandbox without enhanced domains, use https://MyDomainName--SandboxName.my.salesforce.com.
- For sandbox with enhanced domains, use https://MyDomainName--SandboxName.sandbox.my.salesforce.com.
For <password>, append a security token to your password if you haven't set up a range of trusted IP addresses. For more information, see Reset Your Security Token and Set Trusted IP Ranges for Your Organization in Salesforce Help.For <channel>, specify /event/Low_Ink__e.The channel format for a custom platform event channel is /event/EventName__e, and for a standard platform event it’s /event/EventName. If instead you want to specify a custom channel, use /event/ChannelName__chn.
1$ java -classpath target/emp-connector-0.0.1-SNAPSHOT-phat.jar com.salesforce.emp.connector.example.DevLoginExample <login_URL> <username> <password> <channel>
Optionally, you can specify a replay option as the last argument. Valid values are:
- –1: Get all new events sent after subscription. This option is the default.
- –2: Get all new events sent after subscription and all past events within the retention window. Use -2 sparingly. If a large volume of event messages is stored, retrieving all event messages can slow performance.
- Specific number: Get all events that occurred after the event with the specified replay ID.
The client is now subscribed to events. In the next step, publish some events and receive them in the client.