AWS Kinesis Firehose
Since Camel 3.2
Only producer is supported
The AWS2 Kinesis Firehose component supports sending messages to Amazon Kinesis Firehose service (Batch not supported).
Prerequisites
You must have a valid Amazon Web Services developer account, and be signed up to use Amazon Kinesis Firehose. More information is available at AWS Kinesis Firehose
URI Format
aws2-kinesis-firehose://delivery-stream-name[?options] The stream needs to be created prior to it being used.
You can append query options to the URI in the following format:
?options=value&option2=value&…
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties,*.yamlfiles, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The AWS Kinesis Firehose component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
The Firehose client does not use the CBOR format of the AWS SDK: it always uses JSON. When false, the endpoint only sets the JVM system property aws.cborEnabled to false when it starts, and clears it when it stops. The property applies to the AWS SDK clients that use CBOR, such as those of Kinesis, created in the JVM while it is set. | true | boolean | |
The configuration that the endpoints of this component start from. Each endpoint gets a copy of it, and the options of the endpoint replace its values. | KinesisFirehose2Configuration | ||
Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set. | false | boolean | |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
The operation to perform. If not set, the producer sends the message body as one record, with PutRecord. sendBatchRecord sends several records with PutRecordBatch, and createDeliveryStream, deleteDeliveryStream, describeDeliveryStream and updateDestination call the Firehose API of the same name. The CamelAwsKinesisFirehoseOperation header overrides it. Enum values:
| KinesisFirehose2Operations | ||
The AWS region of Amazon Data Firehose, as a region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the default region provider chain of the AWS SDK is used. Enum values:
| String | ||
The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true. | String | ||
Whether the Firehose client loads the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options. | false | boolean | |
Autowired To use a custom software.amazon.awssdk.services.firehose.FirehoseClient for all the requests of this endpoint, which is autowired when the registry has a single one. When this option is set, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used. | FirehoseClient | ||
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
The host name of the proxy that the HTTP client of Firehose connects through. The proxy is used only when the proxyPort option is set too. | String | ||
The port of the proxy that the HTTP client of Firehose connects through. The proxy is used only when the proxyHost option is set too. | Integer | ||
The protocol that the HTTP client of Firehose uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set. Enum values:
| HTTPS | Protocol | |
The access key ID of the AWS credentials, used together with the secretKey option. The endpoint requires it, unless amazonKinesisFirehoseClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true. | String | ||
The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change. | String | ||
The secret access key of the AWS credentials, used together with the accessKey option. The endpoint requires it, unless amazonKinesisFirehoseClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true. | String | ||
The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. All three are then required: if one of the three is missing, creating the client fails. | String | ||
Whether the HTTP client of Firehose trusts every TLS certificate without checking it, with or without an endpoint override. Use it only for testing, for example against a local emulator. | false | boolean | |
Whether the Firehose client loads the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials. | false | boolean | |
Whether the Firehose client uses temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true. | false | boolean |
Endpoint Options
The AWS Kinesis Firehose endpoint is configured using URI syntax:
aws2-kinesis-firehose:streamName
With the following path and query parameters:
Path Parameters
| Name | Description | Default | Type |
|---|---|---|---|
Required The name of the Firehose delivery stream that the producer sends the records to: one record with PutRecord, or, for the sendBatchRecord operation with a List body, the records of the List with PutRecordBatch. The other operations take the delivery stream from the request in the body, or from the CamelAwsKinesisFirehoseDeliveryStreamName header. | String |
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
The Firehose client does not use the CBOR format of the AWS SDK: it always uses JSON. When false, the endpoint only sets the JVM system property aws.cborEnabled to false when it starts, and clears it when it stops. The property applies to the AWS SDK clients that use CBOR, such as those of Kinesis, created in the JVM while it is set. | true | boolean | |
Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set. | false | boolean | |
The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true. | String | ||
The operation to perform. If not set, the producer sends the message body as one record, with PutRecord. sendBatchRecord sends several records with PutRecordBatch, and createDeliveryStream, deleteDeliveryStream, describeDeliveryStream and updateDestination call the Firehose API of the same name. The CamelAwsKinesisFirehoseOperation header overrides it. Enum values:
| KinesisFirehose2Operations | ||
The AWS region of Amazon Data Firehose, as a region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the default region provider chain of the AWS SDK is used. Enum values:
| String | ||
Whether the Firehose client loads the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options. | false | boolean | |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
Autowired To use a custom software.amazon.awssdk.services.firehose.FirehoseClient for all the requests of this endpoint, which is autowired when the registry has a single one. When this option is set, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used. | FirehoseClient | ||
The host name of the proxy that the HTTP client of Firehose connects through. The proxy is used only when the proxyPort option is set too. | String | ||
The port of the proxy that the HTTP client of Firehose connects through. The proxy is used only when the proxyHost option is set too. | Integer | ||
The protocol that the HTTP client of Firehose uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set. Enum values:
| HTTPS | Protocol | |
The access key ID of the AWS credentials, used together with the secretKey option. The endpoint requires it, unless amazonKinesisFirehoseClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true. | String | ||
The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change. | String | ||
The secret access key of the AWS credentials, used together with the accessKey option. The endpoint requires it, unless amazonKinesisFirehoseClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true. | String | ||
The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. All three are then required: if one of the three is missing, creating the client fails. | String | ||
Whether the HTTP client of Firehose trusts every TLS certificate without checking it, with or without an endpoint override. Use it only for testing, for example against a local emulator. | false | boolean | |
Whether the Firehose client loads the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials. | false | boolean | |
Whether the Firehose client uses temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true. | false | boolean |
Message Headers
The AWS Kinesis Firehose component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
CamelAwsKinesisFirehoseRecordId (producer) Constant: | Set by the producer after it sent a single record: the ID that Firehose gave the record. | String | |
CamelAwsKinesisFirehoseOperation (producer) Constant: | The operation to perform, which overrides the operation option: sendBatchRecord, createDeliveryStream, deleteDeliveryStream, describeDeliveryStream or updateDestination. | String | |
CamelAwsKinesisFirehoseDeliveryStreamName (producer) Constant: | The name of the delivery stream that the deleteDeliveryStream and describeDeliveryStream operations act on, when the body is not their request. The other operations and the sending of a single record do not use it. | String | |
CamelAwsKinesisFirehoseDeliveryStreamArn (createDeliveryStream) Constant: | Set after the createDeliveryStream and describeDeliveryStream operations: the ARN of the delivery stream. | String | |
CamelAwsKinesisFirehoseFailedRecordCount (sendBatchRecord) Constant: | Set after the sendBatchRecord operation: the number of records that Firehose did not write (the FailedPutCount of the response). The producer does not send them again, and the exchange does not fail. | Integer | |
CamelAwsKinesisFirehoseEncrypted (sendBatchRecord) Constant: | Set after the sendBatchRecord operation: whether server-side encryption (SSE) was enabled for the PutRecordBatch request. | Boolean | |
CamelAwsKinesisFirehoseDeliveryStreamStatus (describeDeliveryStream) Constant: | Set after the describeDeliveryStream operation: the status of the delivery stream, such as CREATING, ACTIVE or DELETING. | String |
Message Body
The message body at each side of the AWS Kinesis Firehose component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.
| Side | Body | Description |
|---|---|---|
Producer input |
| The data of the record, when no operation is set: text, bytes, a stream or a file. A Map, a List or a POJO fails, and a number is sent as its binary value: marshal it or convert it to text first. sendBatchRecord takes a List of the Record of the Firehose SDK or a PutRecordBatchRequest, and the other operations their request of the AWS SDK, or for deleteDeliveryStream and describeDeliveryStream the CamelAwsKinesisFirehoseDeliveryStreamName header.
|
Producer output |
| Unchanged after a send, with the id of the record in a header; the response of the AWS SDK for the operations.
|
The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.
Required Kinesis Firehose component options
You have to provide the FirehoseClient in the Registry with proxies and relevant credentials configured.
Usage
Static credentials, Default Credential Provider and Profile Credentials Provider
You have the possibility of avoiding the usage of explicit static credentials by specifying the useDefaultCredentialsProvider option and set it to true.
The order of evaluation for Default Credentials Provider is the following:
-
Java system properties -
aws.accessKeyIdandaws.secretKey -
Environment variables -
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY. -
Web Identity Token from AWS STS.
-
The shared credentials and config files.
-
Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable
AWS_CONTAINER_CREDENTIALS_RELATIVE_URIis set. -
Amazon EC2 Instance profile credentials.
You have also the possibility of using Profile Credentials Provider, by specifying the useProfileCredentialsProvider option to true and profileCredentialsName to the profile name.
Only one of static, default and profile credentials could be used at the same time.
For more information about this you can look at AWS credentials documentation
Amazon Kinesis Firehose configuration
You then have to reference the FirehoseClient in the amazonKinesisFirehoseClient URI option.
-
Java
-
XML
-
YAML
from("direct:start")
.to("aws2-kinesis-firehose://mykinesisdeliverystream?amazonKinesisFirehoseClient=#kinesisClient")
.to("log:out?showAll=true"); <route>
<from uri="direct:start"/>
<to uri="aws2-kinesis-firehose://mykinesisdeliverystream?amazonKinesisFirehoseClient=#kinesisClient"/>
<to uri="log:out?showAll=true"/>
</route> - route:
from:
uri: direct:start
steps:
- to:
uri: aws2-kinesis-firehose://mykinesisdeliverystream
parameters:
amazonKinesisFirehoseClient: "#kinesisClient"
- to:
uri: log:out
parameters:
showAll: true Providing AWS Credentials
It is recommended that the credentials are obtained by using the DefaultAWSCredentialsProviderChain that is the default when creating a new ClientConfiguration instance, however, a different AWSCredentialsProvider can be specified when calling createClient(…).
Kinesis Firehose Producer operations
Camel-AWS s3 component provides the following operation on the producer side:
-
SendBatchRecord
-
CreateDeliveryStream
-
DeleteDeliveryStream
-
DescribeDeliveryStream
-
UpdateDestination
Send Batch Records Example
You can send an iterable of Kinesis Record (as the following example shows), or you can send directly a PutRecordBatchRequest POJO instance in the body.
Record buildersfrom("direct:start")
.process(exchange -> {
exchange.getIn().setBody(List.of(
Record.builder().data(SdkBytes.fromString("Test1", Charset.defaultCharset())).build(),
Record.builder().data(SdkBytes.fromString("Test2", Charset.defaultCharset())).build()));
})
.to("aws2-kinesis-firehose://cc?amazonKinesisFirehoseClient=#FirehoseClient&operation=sendBatchRecord"); In the deliveryStream you’ll find "Test1Test2".
Dependencies
Maven users will need to add the following dependency to their pom.xml.
pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-aws2-kinesis</artifactId>
<version>${camel-version}</version>
</dependency> where ${camel-version} must be replaced by the actual version of Camel.