Connecting to the Streaming API

Overview

The streaming API is built on GraphQL over WebSocket protocol. This protocol defines that a given stream (identified by application key, URL, and chainCode) can only be consumed by one application/process/thread. Therefore, do not use multithreading when connecting to the Streaming API.

Prerequisites

Streaming Business Events from OPERA Cloud requires a minimum version of OPERA Cloud 22.3.0.1.

Before connecting to consume Business Events from the WebSocket, verify the following prerequisites are met:
  • Onboard to OHIP by following the steps in Getting Started for Partners.

  • Create an application by following the steps in Registering an Application.

  • Take a note of the application key.

    Note:

    It is important that you write down the application key.

    You can only connect to the streaming API from one application at a time using the same application key. Using a single application key to simultaneously access the API from multiple applications will stop the streaming service.

  • Add an environment from which to consume events. For more information, see Environments (Gateways and Credentials). Take note of the following:
    • ClientId and ClientSecret — These are needed to obtain the oAuth token.

    • Gateway URL

  • Check that the environment is streaming enabled. It will have a label "Streaming Enabled" if this is the case.

  • Set up the template of events. For more information, see Working with Events and Creating a Template of Events for an Application.

  • Subscribe to consume the events from an environment. For more information, see Working with Events and Subscribing to Events.

If the environment is the partner sandbox or an environment owned by your organization, the request to consume events is automatically approved. If not, environment owners (usually customers) must approve the request to consume events from their environment. To do this, follow the process in Working with Events and Approving Events.

Once the request to consume events is approved, the event is listed as "Approved" on the Developer Portal.

GraphQL

The streaming API uses GraphQL subscriptions delivered through WebSocket. To learn more about this technology, read our blog post.