Creating a Stream

Configure and create a stream in the Streaming service.

Before publishing messages to a stream or consuming messages from a stream, you must first create a stream. When creating a stream, consider your partitioning and security strategies. To review requirements for creating and managing streams, see Getting Started with Streaming.

    1. On the Streams list page, select Create Stream Pool. If you need help finding the list page, see Listing Streams.
    2. Complete the options to create a stream:
      • Stream Name: Enter a name for the stream. The name doesn't have to be unique within the compartment, but must be unique to the stream pool. The stream name can't be changed. Avoid entering confidential information.
      • Compartment: Select the compartment in which to create the stream.
      • Stream Pool: Select the stream pool to contain your stream.

        If the compartment has an existing stream pool, you can select it.

        If no stream pool exists in the compartment, select Create New Stream Pool and configure the stream pool. For instructions, see step 5 in Creating a Stream Pool.

    3. Provide values for Define Stream Settings:
      • Retention (in hours): Enter the number of hours (from 24 to 168) to retain messages in this stream. The default value is 24.
      • Number of Partitions: Enter the number of partitions for the stream. The maximum number is based on the limits for your tenancy.

        The maximum Total Write Rate and Total Read Rate values for the stream are displayed as you adjust the number of partitions.

    4. (Optional) Add one or more tags to the stream: Select Show Advanced Options to show the Add Tags section.
      If you have permissions to create a resource, then you also have permissions to apply free-form tags to that resource. To apply a defined tag, you must have permissions to use the tag namespace. For more information about tagging, see Resource Tags. If you're not sure whether to apply tags, skip this option or ask an administrator. You can apply tags later.
    5. Select Create.
  • 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.

    Note

    The examples in this section use the full syntax for all parameters, for example --compartment-id. For some parameters, there are shortened versions that you can use instead, like -c. See the CLI online help for instances of a shortened parameter associated with a command.

    You can create a stream in a compartment or a stream pool. The --compartment-id and --stream-pool-id parameters cannot be specified at the same time.

    oci streaming admin stream create --name <stream_name> --partitions <number_of_partitions> --compartment-id <compartment_OCID>
    oci streaming admin stream create --name <stream_name> --partitions <number_of_partitions> --stream-pool-id <stream_pool_OCID>

    For example:

    oci streaming admin stream create --name MyStream --partitions 5 --compartment-id ocid1.tenancy.oc1..exampleuniqueID
    {
      "data": {
        "compartment-id": "ocid1.tenancy.oc1..exampleuniqueID",
        "defined-tags": {},
        "freeform-tags": {},
        "id": "ocid1.stream.oc1.phx.exampleuniqueID",
        "lifecycle-state": "CREATING",
        "lifecycle-state-details": null,
        "messages-endpoint": "https://cell-1.streaming.us-phoenix-1.oci.oraclecloud.com",
        "name": "MyStream",
        "partitions": 5,
        "retention-in-hours": 24,
        "stream-pool-id": "ocid1.streampool.oc1.phx.exampleuniqueID",
        "time-created": "2020-11-02T19:12:22.385000+00:00"
      },
      "etag": "\"d72d8103-f1ae-442a-822d-10f86cd097c5-25e61a9b-cc08-4fad-9908-40c9636d31d8\""
    }
  • Use the CreateStream API operation to create streams.

    For information about using the API and signing requests, see REST API documentation and Security Credentials. For information about SDKs, see SDKs and the CLI.

Using OCI SDKs

To create a stream, use the createStream method of StreamAdminClient.

See the Developer Guide to Streaming for detailed SDK examples.

Using Resource Manager and Terraform

Use the oci_streaming_stream resource in Terraform configurations to create a stream in a compartment.

For example:

resource "oci_streaming_stream" "stream" {
  compartment_id     = var.compartment_ocid
  name               = "<stream_name>"
  partitions         = "<number_of_partitions>"
  retention_in_hours = "<retention_in_hours>"
}
About Resource Manager and Terraform

Resource Manager is an Oracle Cloud Infrastructure (OCI) service that allows you to automate the process of provisioning your OCI resources. Using Terraform, Resource Manager helps you install, configure, and manage resources through the "infrastructure-as-code" model.

A Terraform configuration codifies your infrastructure in declarative configuration files. The configuration defines the resources you intend to provision, variables, and specific instructions for provisioning the resources

You can use Resource Manager or the Terraform CLI with the OCI Terraform provider to see how your streams and stream pools are represented in Terraform configuration files.

For more information about writing configurations for use with Resource Manager, see Terraform Configurations for Resource Manager and Terraform Configuration.