Updated on 2024-10-25 GMT+08:00

Creating a Stream

Initialize a DIS SDK client instance named dic. For details, see Initializing a DIS SDK Client Instance.

When you use the DIS SDK to create a DIS stream, specify the stream name, number of partitions in the stream, and stream type.

STREAM_TYPE_COMMON indicates a common stream, and STREAM_TYPE_ADVANCED indicates an advanced stream.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
CreateStreamRequest createStreamRequest = new CreateStreamRequest();
//Configure a stream name.
String streamName = "myStream";
createStreamRequest.setStreamName(streamName);
//Configure a stream type. The value can be Common or Advanced.
createStreamRequest.setStreamType(StreamType.COMMON.name());
//Configure the number of partitions in the stream.
createStreamRequest.setPartitionCount(3);
//Configure the retention period of the stream in units of hours. The value is N x 24, where N ranges from 1 to 7.
createStreamRequest.setDataDuration(24);
//Configure the source data type of the stream. Default value: BLOB
createStreamRequest.setDataType(DataTypeEnum.BLOB.name());

After configuring CreateStreamRequest, you can create a stream by calling createStream.

1
dic.createStream(createStreamRequest);