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

Querying a Stream List

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

You can use the DIS SDK to list active streams.

Use the setLimit method to set the number of streams returned each time. If setLimit is not specified, a maximum of 10 streams are returned by default.

1
2
3
ListStreamsRequest listStreamsRequest = new ListStreamsRequest();
listStreamsRequest.setLimit(5);
System.out.println("listStream: " + JsonUtils.objToJson(dic.listStreams(listStreamsRequest)));
Table 1 Parameters

Parameter

Type

Description

limit

long

The maximum number of DIS streams to list in a single API call.

Value range: 1 to 100

Default value: 10

exclusiveStartStreamName

string

Name of the DIS stream to start the stream list with. The returned stream list does not contain this DIS stream name.

If pagination query is required, this parameter is not transferred when you query data on the first page. If the value of has_more_streams is true, the query is performed on the next page. The value of exclusiveStartStreamName is the name of the last stream in the query result of the first page.

In this demo, start_Stream_Name is defined as a stream name before stream0, and limit is set to 5. The following information is returned:

1
listStream: {"total_number":20,"stream_names":["Stream0","Stream1","Stream2","Stream3","Stream4"],"has_more_streams":true}
Table 2 Response parameter description

Parameter

Type

Description

total_number

Int

Total number of all the DIS streams created by the current tenant.

stream_names

List<String>

List of the streams meeting the current requests.

has_more_streams

Boolean

Specify whether there are more matching DIS streams to list. Possible values:

  • true: There are more streams.
  • false: There are no more partitions.