@Experimental(value=SOURCE_SINK) public final class KinesisIO extends java.lang.Object
PTransforms for reading from
Kinesis streams.
Example usage:
p.apply(KinesisIO.read()
.withStreamName("streamName")
.withInitialPositionInStream(InitialPositionInStream.LATEST)
.withAWSClientsProvider("AWS_KEY", _"AWS_SECRET", STREAM_REGION)
.apply( ... ) // other transformations
As you can see you need to provide 3 things:
InitialPositionInStream.LATEST - reading will begin from end of the streamInitialPositionInStream.TRIM_HORIZON - reading will begin at
the very beginning of the streamAmazonKinesis and AmazonCloudWatch clients:
In case when you want to set up AmazonKinesis or AmazonCloudWatch client by
your own (for example if you're using more sophisticated authorization methods like Amazon
STS, etc.) you can do it by implementing AWSClientsProvider class:
public class MyCustomKinesisClientProvider implements AWSClientsProvider {
{@literal @}Override
public AmazonKinesis getKinesisClient() {
// set up your client here
}
public AmazonCloudWatch getCloudWatchClient() {
// set up your client here
}
}
Usage is pretty straightforward:
p.apply(KinesisIO.read()
.withStreamName("streamName")
.withInitialPositionInStream(InitialPositionInStream.LATEST)
.withAWSClientsProvider(new MyCustomKinesisClientProvider())
.apply( ... ) // other transformations
There’s also possibility to start reading using arbitrary point in time -
in this case you need to provide Instant object:
p.apply(KinesisIO.read()
.withStreamName("streamName")
.withInitialTimestampInStream(instant)
.withAWSClientsProvider(new MyCustomKinesisClientProvider())
.apply( ... ) // other transformations
| Modifier and Type | Class and Description |
|---|---|
static class |
KinesisIO.Read
Implementation of
read(). |
| Constructor and Description |
|---|
KinesisIO() |
| Modifier and Type | Method and Description |
|---|---|
static KinesisIO.Read |
read()
Returns a new
KinesisIO.Read transform for reading from Kinesis. |
public static KinesisIO.Read read()
KinesisIO.Read transform for reading from Kinesis.