Example: Subscribe to and Replay Events Using a Lightning Component
Previous Versions
Check out code examples for streaming events in Java, Aura components, and Visualforce.
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.
Example: Subscribe to and Replay Events Using a Lightning Component
Subscribe to event streaming channels with the empApi component in your Lightning web component or Aura component. The empApi component provides access to methods for subscribing to a streaming channel and listening to event messages.
Example: Interactive Visualforce Page without Replay
The interactive Visualforce example shows you how to implement Streaming API from a Visualforce page. The sample uses the Dojo library and CometD to subscribe to PushTopic events.
You can set up a simple authentication scheme for developer testing. For production systems, use robust authorization, such as OAuth 2.0.