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 EMP Connector sample is deprecated and will be archived in the future. The EMP Connector code is an example only and isn’t intended for production environments. It hasn’t been rigorously tested nor performance tested for throughput and scale.

Are you looking for a code sample for subscribing to platform events and change events? Check out the Java Quick Start for Pub/Sub API in the Pub/Sub API Guide.

Important

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 (legacy)
  • Generic events (legacy)

EMP Connector is based on Java 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