Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Subscribing to DLE Server-Sent Events

 

Use the Cloud Analytics Engine DLE API as follows to subscribe to and receive Server-Sent Events notifications relevant to DLE clients.

GET /api/v1/events

Use this DLE API request to subscribe to DLE Server-Sent Events (SSE), which enables server-to-client streaming of text-based event data of interest to DLE component clients.

A DLE SSE event notification is delivered as a streaming HTTP response. The client initiates a regular HTTP request, the server responds with a custom text/event-stream content-type, and then the server streams UTF-8 encoded event data. When new events occur, data about the events is sent to subscribed clients as JSON objects.

  • The event payload is formatted as defined by the particular event.

  • The HTTP client or library used to run this API must be able to read responses incrementally as the data is available, rather than wait until the entire response has been received. Compatible clients or libraries include curl/libcurl and Apache HttpClient.

  • The connection established in the subscription is kept alive by keep-alive messages (newlines with no other data) sent to the client periodically.

Event notifications supported by DLE:

  • Compute Agent (CA) list updates: Notification that DLE has updated its list of known, active CA components.

    Event data format:

    • caListUpdated: Event name.

    • timeInMillis: Timestamp of CA list update (epoch time in ms).

    Sample event data in JSON format:

    {"caListUpdated":{"timeInMillis":1418838003802}}

    See DLE API GET /api/v1/compute-agents for details on how to retrieve information about available CA component information, which is required for activating flow traces using DLE API POST /api/v1/traces).

Request Parameters:

  • None

Response Data:

Server-Sent Events Data Learning Engine API Example

The following is a DLE API example of subscribing to and receiving Server-Sent Events (SSEs) data for Compute Agents list update events. See GET /api/v1/events for details on DLE Server-Sent Events subscription.

Request to subscribe to all available SSEs (GET method):

http://localhost:8282/api/vi/events

Streamed Event response data with keep-alive messages: