Camel Components

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&…​

URI Options

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, *.yaml files, 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

cborEnabled (common)

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

configuration (producer)

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

overrideEndpoint (common)

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

lazyStartProducer (producer)

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

operation (producer)

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:

  • sendBatchRecord

  • createDeliveryStream

  • deleteDeliveryStream

  • describeDeliveryStream

  • updateDestination

KinesisFirehose2Operations

region (producer)

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:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

uriEndpointOverride (common)

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

useDefaultCredentialsProvider (common)

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

amazonKinesisFirehoseClient (advanced)

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

autowiredEnabled (advanced)

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

proxyHost (proxy)

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

proxyPort (proxy)

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

proxyProtocol (proxy)

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:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

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

profileCredentialsName (security)

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

secretKey (security)

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

sessionToken (security)

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

trustAllCertificates (security)

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

useProfileCredentialsProvider (security)

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

useSessionCredentials (security)

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

streamName (producer)

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

cborEnabled (common)

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

overrideEndpoint (common)

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

uriEndpointOverride (common)

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

operation (producer)

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:

  • sendBatchRecord

  • createDeliveryStream

  • deleteDeliveryStream

  • describeDeliveryStream

  • updateDestination

KinesisFirehose2Operations

region (producer)

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:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

useDefaultCredentialsProvider (common)

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

lazyStartProducer (producer (advanced))

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

amazonKinesisFirehoseClient (advanced)

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

proxyHost (proxy)

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

proxyPort (proxy)

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

proxyProtocol (proxy)

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:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

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

profileCredentialsName (security)

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

secretKey (security)

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

sessionToken (security)

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

trustAllCertificates (security)

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

useProfileCredentialsProvider (security)

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

useSessionCredentials (security)

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: RECORD_ID

Set by the producer after it sent a single record: the ID that Firehose gave the record.

String

CamelAwsKinesisFirehoseOperation (producer)

Constant: KINESIS_FIREHOSE_OPERATION

The operation to perform, which overrides the operation option: sendBatchRecord, createDeliveryStream, deleteDeliveryStream, describeDeliveryStream or updateDestination.

String

CamelAwsKinesisFirehoseDeliveryStreamName (producer)

Constant: KINESIS_FIREHOSE_STREAM_NAME

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: DELIVERY_STREAM_ARN

Set after the createDeliveryStream and describeDeliveryStream operations: the ARN of the delivery stream.

String

CamelAwsKinesisFirehoseFailedRecordCount (sendBatchRecord)

Constant: FAILED_RECORD_COUNT

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: ENCRYPTED

Set after the sendBatchRecord operation: whether server-side encryption (SSE) was enabled for the PutRecordBatch request.

Boolean

CamelAwsKinesisFirehoseDeliveryStreamStatus (describeDeliveryStream)

Constant: DELIVERY_STREAM_STATUS

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

text, bytes, stream or file

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.

  • With operation=sendBatchRecord: list or pojo

  • With operation=createDeliveryStream: pojo (software.amazon.awssdk.services.firehose.model.CreateDeliveryStreamRequest)

  • With operation=updateDestination: pojo (software.amazon.awssdk.services.firehose.model.UpdateDestinationRequest)

  • With operation=deleteDeliveryStream: any

  • With operation=describeDeliveryStream: any

Producer output

unchanged

Unchanged after a send, with the id of the record in a header; the response of the AWS SDK for the operations.

  • With operation=sendBatchRecord: pojo (software.amazon.awssdk.services.firehose.model.PutRecordBatchResponse)

  • With operation=createDeliveryStream: pojo (software.amazon.awssdk.services.firehose.model.CreateDeliveryStreamResponse)

  • With operation=deleteDeliveryStream: pojo (software.amazon.awssdk.services.firehose.model.DeleteDeliveryStreamResponse)

  • With operation=describeDeliveryStream: pojo (software.amazon.awssdk.services.firehose.model.DescribeDeliveryStreamResponse)

  • With operation=updateDestination: pojo (software.amazon.awssdk.services.firehose.model.UpdateDestinationResponse)

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.accessKeyId and aws.secretKey

  • Environment variables - AWS_ACCESS_KEY_ID and AWS_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_URI is 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.

Java-only: uses AWS SDK Record builders
from("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.