Stateful Functions offers an AWS Kinesis I/O Module for reading from and writing to Kinesis streams.
It is based on Apache Flink’s Kinesis connector.
The Kinesis I/O Module is configurable in Yaml or Java.
To use the Kinesis I/O Module in Java, please include the following dependency in your pom.
Kinesis Ingress Spec
A KinesisIngressSpec declares an ingress spec for consuming from Kinesis stream.
It accepts the following arguments:
The AWS region
An AWS credentials provider
A KinesisIngressDeserializer for deserializing data from Kinesis (Java only)
The stream start position
Properties for the Kinesis client
The name of the stream to consume from
The ingress also accepts properties to directly configure the Kinesis client, using KinesisIngressBuilder#withClientConfigurationProperty().
Please refer to the Kinesis client configuration documentation for the full list of available properties.
Note that configuration passed using named methods will have higher precedence and overwrite their respective settings in the provided properties.
Startup Position
The ingress allows configuring the startup position to be one of the following:
Latest (default)
Start consuming from the latest position, i.e. head of the stream shards.
Earlist
Start consuming from the earliest position possible.
Date
Starts from offsets that have an ingestion time larger than or equal to a specified date.
Kinesis Deserializer
The Kinesis ingress needs to know how to turn the binary data in Kinesis into Java objects.
The KinesisIngressDeserializer allows users to specify such a schema.
The T deserialize(IngressRecord ingressRecord) method gets called for each Kinesis record, passing the binary data and metadata from Kinesis.
Kinesis Egress Spec
A KinesisEgressBuilder declares an egress spec for writing data out to a Kinesis stream.
It accepts the following arguments:
The egress identifier associated with this egress
The AWS credentials provider
A KinesisEgressSerializer for serializing data into Kinesis (Java only)
The AWS region
Properties for the Kinesis client
The number of max outstanding records before backpressure is applied
The Kinesis egress needs to know how to turn Java objects into binary data.
The KinesisEgressSerializer allows users to specify such a schema.
The EgressRecord serialize(T value) method gets called for each message, allowing users to set a value, and other metadata.
AWS Region
Both the Kinesis ingress and egress can be configured to a specific AWS region.
Default Provider Chain (default)
Consults AWS’s default provider chain to determine the AWS region.
Specific
Specifies an AWS region using the region’s unique id.
Custom Endpoint
Connects to an AWS region through a non-standard AWS service endpoint.
This is typically used only for development and testing purposes.
AWS Credentials
Both the Kinesis ingress and egress can be configured using standard AWS credential providers.
Default Provider Chain (default)
Consults AWS’s default provider chain to determine the AWS credentials.
Basic
Specifies the AWS credentials directly with provided access key ID and secret access key strings.
Profile
Specifies the AWS credentials using an AWS configuration profile, along with the profile’s configuration path.