Consuming with the Console, CLI, and API

While you can use the Console to view the latest messages in a stream, you should use the CLI, API, or an SDK to manage cursors and consume from your stream.

To consume messages using the Oracle Cloud Infrastructure (OCI) SDKs, see the Developer Guide to Streaming.

If you take advantage of Streaming's Kafka compatbility, see Developing with Kafka and Streaming.

Tip

You can also use Oracle Cloud Infrastructure Service Connector Hub to consume data from a stream and pass messages to Object Storage or any other supported Service Connector Hub target.

Using the Console

You cannot use the Console to consume messages, but you can use it to show recent messages on a stream:

  1. Open the navigation menu and click Analytics & AI. Under Messaging, click Streaming.
  2. Click a stream to display the stream details page.
  3. In the Recent Messages panel, click Load Messages.
Note

Streams using private endpoints are not accessible from the internet, so their messages do not display in the Console.

Using the Command Line Interface (CLI)

For information about using the CLI, see Command Line Interface (CLI). For a complete list of flags and options available for CLI commands, see the Command Line Reference.

To create a cursor

oci streaming stream cursor create-cursor --stream-id <stream_OCID> --partition <partition> --type <cursor_type> --endpoint <messages_endpoint>

For example:

oci streaming stream cursor create-cursor --stream-id ocid1.stream.oc1.phx.exampleuniqueID --partition 0 --type TRIM_HORIZON --endpoint https://cell-1.streaming.us-phoenix-1.oci.oraclecloud.com
{
  "data": {
    "value": "examplecursorvalue"
  }
}
To create a group cursor

oci streaming stream cursor create-group-cursor --stream-id <stream_OCID> --group-name <consumer_group_name> --type <cursor_type> --endpoint <messages_endpoint>

For example:

oci streaming stream cursor create-group-cursor --stream-id ocid1.stream.oc1.phx.exampleuniqueID --group-name MyConsumerGroup --type TRIM_HORIZON --endpoint https://cell-1.streaming.us-phoenix-1.oci.oraclecloud.com
{
  "data": {
    "value": "examplegroupcursorvalue"
  }
}
To get messages

oci streaming stream message get --stream-id <stream_OCID> --cursor <cursor> --endpoint <messages_endpoint>

Your first request to get messages should use the value returned when you created a cursor. Each subsequent request should use the opc-next-cursor value returned in the previous response.

For example:

oci streaming stream message get --stream-id ocid1.stream.oc1.phx.exampleuniqueID --cursor examplecursorvalue --endpoint https://cell-1.streaming.us-phoenix-1.oci.oraclecloud.com
{
  "data": [
    {
      "key": "a2V5MQ==",
      "offset": 0,
      "partition": "0",
      "stream": "MyStream",
      "timestamp": "2020-11-03T21:52:58.470000+00:00",
      "value": "dmFsdWUx"
    },
    {
      "key": "a2V5Mg==",
      "offset": 1,
      "partition": "0",
      "stream": "MyStream",
      "timestamp": "2020-11-03T21:52:58.470000+00:00",
      "value": "dmFsdWUy"
    },
    {
      "key": "a2V5MQ==",
      "offset": 2,
      "partition": "0",
      "stream": "MyStream",
      "timestamp": "2020-11-03T22:00:48.305000+00:00",
      "value": "dmFsdWUx"
    },
    {
      "key": "a2V5Mg==",
      "offset": 3,
      "partition": "0",
      "stream": "MyStream",
      "timestamp": "2020-11-03T22:00:48.305000+00:00",
      "value": "dmFsdWUy"
    }
  ],
  "opc-next-cursor": "examplenextcursorvalue"
}
To send a heartbeat

oci streaming stream group heartbeat --stream-id <stream_OCID> --cursor <cursor> --endpoint <messages_endpoint>

Your first heartbeat request should use the value returned when you created a group cursor. Each subsequent request should use the value returned in the previous response.

For example:

oci streaming stream group heartbeat --stream-id ocid1.stream.oc1.phx.exampleuniqueID --cursor examplecursorvalue --endpoint https://cell-1.streaming.us-phoenix-1.oci.oraclecloud.com
{
  "data": {
    "value": "examplenextcursorvalue"
  }
}