AWS RedshiftData
Since Camel 4.1
Only producer is supported
The AWS2 Redshift Data component supports the following operations on AWS Redshift:
-
listDatabases, listSchemas, listStatements, listTables, describeTable, executeStatement, batchExecuteStatement, cancelStatement, describeStatement, getStatementResult
Prerequisites
You must have a valid Amazon Web Services developer account, and be signed up to use Amazon Redshift. More information is available at AWS Redshift.
URI Format
aws2-redshift-data://label[?options]
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 RedshiftData component supports the following options which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
The configuration that the component copies to each endpoint that it creates, so that the endpoints share its values. | RedshiftData2Configuration | ||
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 that the producer performs. The CamelAwsRedshiftDataOperation header replaces this option. If neither is set, the exchange fails. Enum values:
| RedshiftData2Operations | ||
Whether the client sends its requests to the URI of uriEndpointOverride instead of the endpoint of the AWS region. Without uriEndpointOverride this option has no effect. | false | boolean | |
Whether the message body is the request of the AWS SDK for the operation, such as an ExecuteStatementRequest for executeStatement, which the producer sends as it is. If true, the headers are not used and a body of another type fails the exchange. | false | boolean | |
The name of the profile that the client loads when useProfileCredentialsProvider is true. If not set, the AWS SDK uses the profile that the AWS_PROFILE environment variable or the aws.profile system property names, or else the profile named default. | String | ||
The AWS region of the Redshift Data API, as a lowercase region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the AWS SDK takes the region from its default region provider chain, such as the aws.region system property or the AWS_REGION environment variable. Enum values:
| String | ||
Whether the HTTP client trusts all TLS certificates without validating them. It applies to every connection of the client, also when the endpoint is not overridden. | false | boolean | |
The URI that the client sends its requests to, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true. | String | ||
Whether the client loads the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the profile files, and the container and instance metadata. It takes precedence over the other credentials options. | false | boolean | |
Whether the client loads the credentials from a profile of the AWS config and credentials files, the one that profileCredentialsName names. It takes precedence over useSessionCredentials, accessKey and secretKey, but not over useDefaultCredentialsProvider. | false | boolean | |
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 | |
Autowired To use a custom software.amazon.awssdk.services.redshiftdata.RedshiftDataClient. When this option is set or autowired, the endpoint does not build a client of its own, so the credentials, region, proxy and endpoint override options are not used. The endpoint does not close a client that is set or autowired. | RedshiftDataClient | ||
Used for enabling or disabling all consumer based health checks from this component. | true | boolean | |
Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true. | true | boolean | |
The host name of the proxy that the client sends its requests through. The proxy is used only when proxyPort is set as well. | String | ||
The port of the proxy that the client sends its requests through. The proxy is used only when proxyHost is set as well. | Integer | ||
The protocol that the client uses to connect to the proxy. It is used only when proxyHost and proxyPort are set. Enum values:
| HTTPS | Protocol | |
The access key ID of the AWS credentials. The client uses it with secretKey as static credentials, or with secretKey and sessionToken when useSessionCredentials is true. | String | ||
The secret access key of the AWS credentials, which the client uses together with accessKey. | String | ||
The session token of temporary AWS credentials, for example from assuming an IAM role. The client uses it only when useSessionCredentials is true, together with accessKey and secretKey. | String | ||
Whether the client uses temporary session credentials made of accessKey, secretKey and sessionToken, for example after assuming an IAM role. If sessionToken is not set, the client uses accessKey and secretKey as static credentials. | false | boolean |
Endpoint Options
The AWS RedshiftData endpoint is configured using URI syntax:
aws2-redshift-data:label
With the following path and query parameters:
Query Parameters
| Name | Description | Default | Type |
|---|---|---|---|
The operation that the producer performs. The CamelAwsRedshiftDataOperation header replaces this option. If neither is set, the exchange fails. Enum values:
| RedshiftData2Operations | ||
Whether the client sends its requests to the URI of uriEndpointOverride instead of the endpoint of the AWS region. Without uriEndpointOverride this option has no effect. | false | boolean | |
Whether the message body is the request of the AWS SDK for the operation, such as an ExecuteStatementRequest for executeStatement, which the producer sends as it is. If true, the headers are not used and a body of another type fails the exchange. | false | boolean | |
The name of the profile that the client loads when useProfileCredentialsProvider is true. If not set, the AWS SDK uses the profile that the AWS_PROFILE environment variable or the aws.profile system property names, or else the profile named default. | String | ||
The AWS region of the Redshift Data API, as a lowercase region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the AWS SDK takes the region from its default region provider chain, such as the aws.region system property or the AWS_REGION environment variable. Enum values:
| String | ||
Whether the HTTP client trusts all TLS certificates without validating them. It applies to every connection of the client, also when the endpoint is not overridden. | false | boolean | |
The URI that the client sends its requests to, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true. | String | ||
Whether the client loads the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the profile files, and the container and instance metadata. It takes precedence over the other credentials options. | false | boolean | |
Whether the client loads the credentials from a profile of the AWS config and credentials files, the one that profileCredentialsName names. It takes precedence over useSessionCredentials, accessKey and secretKey, but not over useDefaultCredentialsProvider. | 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.redshiftdata.RedshiftDataClient. When this option is set or autowired, the endpoint does not build a client of its own, so the credentials, region, proxy and endpoint override options are not used. The endpoint does not close a client that is set or autowired. | RedshiftDataClient | ||
The host name of the proxy that the client sends its requests through. The proxy is used only when proxyPort is set as well. | String | ||
The port of the proxy that the client sends its requests through. The proxy is used only when proxyHost is set as well. | Integer | ||
The protocol that the client uses to connect to the proxy. It is used only when proxyHost and proxyPort are set. Enum values:
| HTTPS | Protocol | |
The access key ID of the AWS credentials. The client uses it with secretKey as static credentials, or with secretKey and sessionToken when useSessionCredentials is true. | String | ||
The secret access key of the AWS credentials, which the client uses together with accessKey. | String | ||
The session token of temporary AWS credentials, for example from assuming an IAM role. The client uses it only when useSessionCredentials is true, together with accessKey and secretKey. | String | ||
Whether the client uses temporary session credentials made of accessKey, secretKey and sessionToken, for example after assuming an IAM role. If sessionToken is not set, the client uses accessKey and secretKey as static credentials. | false | boolean |
Message Headers
The AWS RedshiftData component supports the following message header(s), which is/are listed below:
| Name | Description | Default | Type |
|---|---|---|---|
CamelAwsRedshiftDataOperation (producer) Constant: | The operation to perform. It replaces the operation option. | String | |
CamelAwsRedshiftDataClusterIdentifier (producer) Constant: | The identifier of the provisioned cluster to connect to. Amazon Redshift requires it for a cluster with AWS Secrets Manager or temporary credentials. For listStatements it is a filter: only the statements that ran on this cluster are returned. Not used by cancelStatement, describeStatement and getStatementResult. | String | |
CamelAwsRedshiftDataSecretArn (producer) Constant: | The name or ARN of the secret in AWS Secrets Manager that holds the user name and password of the database. Amazon Redshift requires it when it authenticates with AWS Secrets Manager. Not used by listStatements, cancelStatement, describeStatement and getStatementResult. | String | |
CamelAwsRedshiftDataDatabase (producer) Constant: | The name of the database. For listSchemas, listTables and describeTable it is the database that holds the schemas or tables, and also the database to connect to when CamelAwsRedshiftDataConnectedDatabase is not set. For listStatements, together with CamelAwsRedshiftDataClusterIdentifier or CamelAwsRedshiftDataWorkGroupName, it is a filter: only the statements that ran in this database are returned. Not used by cancelStatement, describeStatement and getStatementResult. | String | |
CamelAwsRedshiftDataWorkGroupName (producer) Constant: | The name or ARN of the Amazon Redshift Serverless workgroup to connect to. Amazon Redshift requires it for a workgroup with AWS Secrets Manager or temporary credentials. For listStatements it is a filter: only the statements that ran in this workgroup are returned. Not used by cancelStatement, describeStatement and getStatementResult. | String | |
CamelAwsRedshiftDataDatabasesMaxResults (producer) Constant: | The maximum number of databases that listDatabases returns in one page. The response holds the nextToken of the next page, for CamelAwsRedshiftDataNextToken. | Integer | |
CamelAwsRedshiftDataDbUser (producer) Constant: | The database user name. Amazon Redshift requires it to connect to a cluster as a database user with temporary credentials. Not used by listStatements, cancelStatement, describeStatement and getStatementResult. | String | |
CamelAwsRedshiftDataConnectedDatabase (producer) Constant: | The database to connect to with the credentials, when it is not the database in CamelAwsRedshiftDataDatabase. Used by listSchemas, listTables and describeTable. | String | |
CamelAwsRedshiftDataSchemaPattern (producer) Constant: | A pattern of schema names for listSchemas and listTables, in which % matches any number of characters and _ matches one character. If not set, all schemas match. | String | |
CamelAwsRedshiftDataSchemasMaxResults (producer) Constant: | The maximum number of schemas that listSchemas returns in one page. The response holds the nextToken of the next page, for CamelAwsRedshiftDataNextToken. | Integer | |
CamelAwsRedshiftDataStatementsMaxResults (producer) Constant: | The maximum number of SQL statements that listStatements returns in one page, at most 100. The response holds the nextToken of the next page, for CamelAwsRedshiftDataNextToken. | Integer | |
CamelAwsRedshiftDataStatementName (producer) Constant: | The name of the SQL statement. executeStatement and batchExecuteStatement give the statement this name, and listStatements returns the statements whose name starts with this value, which is case-sensitive. | String | |
CamelAwsRedshiftDataStatus (producer) Constant: | The status of the statements that listStatements returns: SUBMITTED, PICKED, STARTED, FINISHED, ABORTED, FAILED or ALL. If not set, Amazon Redshift returns only the finished statements. | String | |
CamelAwsRedshiftDataRoleLevel (producer) Constant: | Whether listStatements returns all statements that the IAM role of the caller ran (true), or only those of the current IAM session (false). If not set, Amazon Redshift uses true. | Boolean | |
CamelAwsRedshiftDataTablesMaxResults (producer) Constant: | The maximum number of tables that listTables returns in one page, at most 1000. The response holds the nextToken of the next page, for CamelAwsRedshiftDataNextToken. | Integer | |
CamelAwsRedshiftDataTablePattern (producer) Constant: | A pattern of table names for listTables, in which % matches any number of characters and _ matches one character. If not set, all tables match. | String | |
CamelAwsRedshiftDataTable (producer) Constant: | The name of the table that describeTable describes. If not set, describeTable describes all tables of the matching schemas. | String | |
CamelAwsRedshiftDataSchema (producer) Constant: | The schema of the table that describeTable describes. If not set, the tables of all schemas match. | String | |
CamelAwsRedshiftDataDescribeTableMaxResults (producer) Constant: | The maximum number of columns that describeTable returns in one page, at most 1000. The response holds the nextToken of the next page, for CamelAwsRedshiftDataNextToken. | Integer | |
CamelAwsRedshiftDataStatementId (producer) Constant: | The ID of the SQL statement for cancelStatement, describeStatement and getStatementResult, as the response of executeStatement or batchExecuteStatement returns it. For the result of one statement of a batch, add its number as a suffix, for example :2 for the second. | String | |
CamelAwsRedshiftDataWithEvent (producer) Constant: | Whether Amazon Redshift sends an event to the Amazon EventBridge event bus after the SQL statements run. Used by executeStatement and batchExecuteStatement. | Boolean | |
CamelAwsRedshiftDataClientToken (producer) Constant: | A unique, case-sensitive identifier of at most 64 characters, which makes a retried request idempotent. Used by executeStatement and batchExecuteStatement. | String | |
CamelAwsRedshiftDataSqlStatement (producer) Constant: | The SQL statement that executeStatement runs, which must be a single statement. Unless CamelAwsRedshiftDataWaitTimeSeconds is set, the producer does not wait for the statement to finish: describeStatement and getStatementResult take the ID that the response returns. | String | |
CamelAwsRedshiftDataSqlParameterList (producer) Constant: | The parameters of the SQL statements of executeStatement and batchExecuteStatement, as a java.util.List of software.amazon.awssdk.services.redshiftdata.model.SqlParameter, each with a name and a value. A statement refers to a parameter as :name. | List | |
CamelAwsRedshiftDataSqlStatementList (producer) Constant: | The SQL statements that batchExecuteStatement runs, as a java.util.List of String with at most 40 statements. They run one after the other in a single transaction, which is rolled back if one of them fails, unless CamelAwsRedshiftDataExecutionMode is AUTO_COMMIT. | List | |
CamelAwsRedshiftDataNextToken (producer) Constant: | The token of the page of results to return, from the nextToken of the response of the previous call. Used by listDatabases, listSchemas, listStatements, listTables, describeTable and getStatementResult. | String | |
CamelAwsRedshiftDataWaitTimeSeconds (producer) Constant: | The number of seconds that executeStatement, batchExecuteStatement and getStatementResult wait for the statement to finish before they return. | Integer | |
CamelAwsRedshiftDataExecutionMode (producer) Constant: | How batchExecuteStatement runs the statements: in one transaction (TRANSACTION) or each statement committed on its own (AUTO_COMMIT). | String | |
CamelAwsRedshiftDataResultFormat (producer) Constant: | The format of the result of executeStatement and batchExecuteStatement: JSON (the default) or CSV. The getStatementResult operation reads JSON results only: a CSV result can only be read with GetStatementResultV2 of the AWS API, which this component does not offer. | String | |
CamelAwsRedshiftDataSessionId (producer) Constant: | The ID of the session that executeStatement and batchExecuteStatement run in, as a previous response with CamelAwsRedshiftDataSessionKeepAliveSeconds returns it. | String | |
CamelAwsRedshiftDataSessionKeepAliveSeconds (producer) Constant: | The number of seconds that the session of executeStatement and batchExecuteStatement stays open after the statement ends, so that a later statement can run in it. | Integer |
Message Body
The message body at each side of the AWS RedshiftData 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 |
| Not used: the operations take their input from headers, such as the SQL of executeStatement in CamelAwsRedshiftDataSqlStatement; SQL in the body is not run. With pojoRequest=true the request of the AWS SDK for the operation, such as an ExecuteStatementRequest: another body fails.
|
Producer output |
| The response of the AWS SDK for the operation, such as the ExecuteStatementResponse of executeStatement, which does not wait for the statement, or the GetStatementResultResponse of getStatementResult with one page of records. |
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 Redshift Data component options
You have to provide the awsRedshiftDataClient in the Registry or your accessKey and secretKey to access the AWS Redshift service.
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
Examples
Producer Examples
-
listDatabases: this operation will list redshift databases
-
Java
-
XML
-
YAML
from("direct:listDatabases")
.to("aws2-redshift-data://test?awsRedshiftDataClient=#awsRedshiftDataClient&operation=listDatabases"); <route>
<from uri="direct:listDatabases"/>
<to uri="aws2-redshift-data://test?awsRedshiftDataClient=#awsRedshiftDataClient&operation=listDatabases"/>
</route> - route:
from:
uri: direct:listDatabases
steps:
- to:
uri: aws2-redshift-data://test
parameters:
awsRedshiftDataClient: "#awsRedshiftDataClient"
operation: listDatabases Using a POJO as body
Sometimes building an AWS Request can be complex because of multiple options. We introduce the possibility to use a POJO as body. In AWS Redshift Data there are multiple operations you can submit, as an example for List Databases request, you can do something like:
from("direct:start")
.setBody(ListDatabases.builder().database("database1").build())
.to("aws2-redshift-data://test?awsRedshiftDataClient=#awsRedshiftDataClient&operation=listDatabases&pojoRequest=true") In this way you’ll pass the request directly without the need of passing headers and options specifically related to this operation.
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-redshift</artifactId>
<version>${camel-version}</version>
</dependency> where ${camel-version} must be replaced by the actual version of Camel.