Newer Version Available

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

Example: Subscribe to and Replay Events Using a Java Client (EMP Connector)

The Java sample uses a library called Enterprise Messaging Platform (EMP) Connector. EMP Connector is a thin wrapper around the CometD library. It hides the complexity of creating a CometD client and subscribing to Streaming API in Java. The example subscribes to a channel, receives notifications, and supports replaying events with durable streaming.

The CometD-based subscription mechanism in EMP Connector can receive any type of Salesforce event. Just pass in the channel name of the desired event. For example, the events that EMP Connector can receive include:

  • Platform events
  • Change Data Capture events
  • PushTopic events
  • Generic events

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

EMP Connector is based on Java 8 and uses CometD version 3.1.0. It supports username and password authentication and OAuth bearer token authentication.

The example requires API version 37.0 or later. For a code example that supports earlier API versions, refer to an earlier version of this documentation.

Note