Updated on 2023-06-21 GMT+08:00

Adding a Checkpoint

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

When using the DIS SDK to create a checkpoint, you need to specify the stream name, application name, partition ID, sequence number, and checkpoint type.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
//Specify the stream name.
String streamName = "myStream"; 
//Specify the application name.
String appName = "myApp";
CommitCheckpointRequest commitCheckpointRequest = new CommitCheckpointRequest();
commitCheckpointRequest.setStreamName(streamName);
commitCheckpointRequest.setAppName(appName);
//Specify the sequence number to be submitted.
commitCheckpointRequest.setSequenceNumber("100");
//Specify the partition No.
commitCheckpointRequest.setPartitionId("0");
//Specify the checkpoint type.
commitCheckpointRequest.setCheckpointType(CheckpointTypeEnum.LAST_READ.name());

After configuring CommitCheckpointRequest, add a checkpoint by calling commitCheckpoint.

dic.commitCheckpoint(commitCheckpointRequest);