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.
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>"
}
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.