Package org.apache.pulsar.io.kinesis
Class KinesisSink
java.lang.Object
org.apache.pulsar.io.aws.AbstractAwsConnector
org.apache.pulsar.io.kinesis.KinesisSink
- All Implemented Interfaces:
AutoCloseable,Sink<org.apache.pulsar.client.api.schema.GenericObject>
public class KinesisSink
extends AbstractAwsConnector
implements Sink<org.apache.pulsar.client.api.schema.GenericObject>
A Kinesis sink which can be configured by
KinesisSinkConfig.
KinesisSinkConfigaccepts 1. awsEndpoint: kinesis end-point url can be found at : https://docs.aws.amazon.com/general/latest/gr/rande.html 2. awsRegion: appropriate aws region eg: us-west-1, us-west-2 3. awsKinesisStreamName: kinesis stream name 4. awsCredentialPluginName: Fully-Qualified class name of implementation ofAwsCredentialProviderPlugin. - It is a factory class which creates anAWSCredentialsProviderthat will be used byKinesisProducer- If it is empty thenKinesisSinkcreates defaultAWSCredentialsProviderwhich accepts json-map of credentials in awsCredentialPluginParam eg: awsCredentialPluginParam = {"accessKey":"my-access-key","secretKey":"my-secret-key"} 5. awsCredentialPluginParam: json-parameters to initializeAwsCredentialProviderPlugin6. messageFormat: enum:["ONLY_RAW_PAYLOAD","FULL_MESSAGE_IN_JSON","FULL_MESSAGE_IN_FB"] a. ONLY_RAW_PAYLOAD: publishes raw payload to stream b. FULL_MESSAGE_IN_JSON: publish full message (encryptionCtx + properties + payload) in json format json-schema: {"type":"object","properties":{"encryptionCtx":{"type":"object","properties":{"metadata":{"type":"object","additionalProperties":{"type":"string"}},"uncompressedMessageSize":{"type":"integer"},"keysMetadataMap":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"type":"string"}}},"keysMapBase64":{"type":"object","additionalProperties":{"type":"string"}},"encParamBase64":{"type":"string"},"compressionType":{"type":"string","enum":["NONE","LZ4","ZLIB"]},"batchSize":{"type":"integer"},"algorithm":{"type":"string"}}},"payloadBase64":{"type":"string"},"properties":{"type":"object","additionalProperties":{"type":"string"}}}} Example: {"payloadBase64":"cGF5bG9hZA==","properties":{"prop1":"value"},"encryptionCtx":{"keysMapBase64":{"key1":"dGVzdDE=","key2":"dGVzdDI="},"keysMetadataMap":{"key1":{"ckms":"cmks-1","version":"v1"},"key2":{"ckms":"cmks-2","version":"v2"}},"metadata":{"ckms":"cmks-1","version":"v1"},"encParamBase64":"cGFyYW0=","algorithm":"algo","compressionType":"LZ4","uncompressedMessageSize":10,"batchSize":10}} c. FULL_MESSAGE_IN_FB: publish full message (encryptionCtx + properties + payload) in flatbuffer format d. FULL_MESSAGE_IN_JSON_EXPAND_VALUE: publish full message (topic + key + value + properties + event time) in JSON format using the schema to expand the value in JSON.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.apache.pulsar.io.aws.AbstractAwsConnector
ACCESS_KEY_NAME, SECRET_KEY_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()createKinesisMessage(KinesisSinkConfig.MessageFormat msgFormat, org.apache.pulsar.functions.api.Record<org.apache.pulsar.client.api.schema.GenericObject> record) voidopen(Map<String, Object> config, SinkContext sinkContext) voidwrite(org.apache.pulsar.functions.api.Record<org.apache.pulsar.client.api.schema.GenericObject> record) Methods inherited from class org.apache.pulsar.io.aws.AbstractAwsConnector
createCredentialProvider, createCredentialProviderWithPlugin, defaultCredentialProvider
-
Field Details
-
METRICS_TOTAL_INCOMING
- See Also:
-
METRICS_TOTAL_INCOMING_BYTES
- See Also:
-
METRICS_TOTAL_SUCCESS
- See Also:
-
METRICS_TOTAL_FAILURE
- See Also:
-
-
Constructor Details
-
KinesisSink
public KinesisSink()
-
-
Method Details
-
write
public void write(org.apache.pulsar.functions.api.Record<org.apache.pulsar.client.api.schema.GenericObject> record) throws Exception -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
open
-
createKinesisMessage
public ByteBuffer createKinesisMessage(KinesisSinkConfig.MessageFormat msgFormat, org.apache.pulsar.functions.api.Record<org.apache.pulsar.client.api.schema.GenericObject> record) throws com.fasterxml.jackson.core.JsonProcessingException - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-