Camel Spring Boot

Azure CosmosDB

Store, read and query items in Azure Cosmos DB, and receive the changes of a container from its change feed.

What’s inside

Please refer to the above links for usage and configuration details.

Maven coordinates

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-azure-cosmosdb-starter</artifactId>
</dependency>

Spring Boot Auto-Configuration

The starter supports 32 options, which are listed below.

Name Description Default Type

camel.component.azure-cosmosdb.account-key

The key of the Azure Cosmos DB account, a read-write key or a read-only key, that authorizes the requests when credentialType is SHARED_ACCOUNT_KEY. Not used when the cosmosAsyncClient option is set.

String

camel.component.azure-cosmosdb.autowired-enabled

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

camel.component.azure-cosmosdb.bridge-error-handler

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

Boolean

camel.component.azure-cosmosdb.change-feed-processor-options

The com.azure.cosmos.models.ChangeFeedProcessorOptions of the change feed processor, for example to start from the beginning of the change feed or from a point in time. If not set, the defaults of the SDK apply: at most 100 items per batch, a lease renew interval of 17 seconds, a lease acquire interval of 13 seconds, a lease expiration interval of 60 seconds, a feed poll delay of 5 seconds, no maximum scale count, and only the changes after the first start. The option is a com.azure.cosmos.models.ChangeFeedProcessorOptions type.

ChangeFeedProcessorOptions

camel.component.azure-cosmosdb.configuration

The configuration of the component. Each endpoint that the component creates starts from a copy of it, to which the options of the endpoint are applied. The option is a org.apache.camel.component.azure.cosmosdb.CosmosDbConfiguration type.

CosmosDbConfiguration

camel.component.azure-cosmosdb.connection-sharing-across-clients-enabled

Whether the client shares its connections in Direct mode with the other clients of the JVM that enable this option, such as the clients of other endpoints or of other accounts. The connection settings of the first of these clients, such as its timeouts, then apply to all of them.

false

Boolean

camel.component.azure-cosmosdb.consistency-level

The default consistency level of the requests of the client. It must be the same as or weaker than the default consistency level of the account. From the strongest to the weakest: Strong, BoundedStaleness, Session, ConsistentPrefix and Eventual.

session

ConsistencyLevel

camel.component.azure-cosmosdb.container-partition-key-path

The partition key path of a container that the component creates, for example /myPartitionKey. A / is added in front when it is missing. Required by createContainer and when createContainerIfNotExists is true, and the CamelAzureCosmosDbContainerPartitionKeyPath header replaces it for the producer.

String

camel.component.azure-cosmosdb.content-response-on-write-enabled

Whether Cosmos DB returns the item in the response of createItem, upsertItem and replaceItem, which the producer then sets as the body. If false, the body is null after these operations, which saves network traffic. The consumer requires true: its change feed processor fails to start with false.

true

Boolean

camel.component.azure-cosmosdb.cosmos-async-client

To use a custom com.azure.cosmos.CosmosAsyncClient for all requests. When this option is set or autowired, the databaseEndpoint, accountKey, credentialType, consistencyLevel, preferredRegions, clientTelemetryEnabled, connectionSharingAcrossClientsEnabled, multipleWriteRegionsEnabled, readRequestsFallbackEnabled and contentResponseOnWriteEnabled options are not used. The endpoint does not close a client that is set or autowired. The option is a com.azure.cosmos.CosmosAsyncClient type.

CosmosAsyncClient

camel.component.azure-cosmosdb.create-container-if-not-exists

Whether to create the container when it does not exist, with the containerPartitionKeyPath and throughputProperties options, and the indexingPolicy option for the producer. The consumer creates it when it starts, and the producer before replaceContainerThroughput and each operation on items except deleteItem. The CamelAzureCosmosDbCreateContainerIfNotExist header replaces it for the producer.

false

Boolean

camel.component.azure-cosmosdb.create-database-if-not-exists

Whether to create the database when it does not exist, with the throughputProperties option. The consumer creates it when it starts, and the producer before each operation on the database, its containers or their items, except deleteDatabase and deleteContainer. The CamelAzureCosmosDbCreateDatabaseIfNotExist header replaces it for the producer.

false

Boolean

camel.component.azure-cosmosdb.create-lease-container-if-not-exists

Whether the consumer creates the lease container when it does not exist, with the partition key path /id and the throughputProperties option.

false

Boolean

camel.component.azure-cosmosdb.create-lease-database-if-not-exists

Whether the consumer creates the lease database when it does not exist, with the throughputProperties option.

false

Boolean

camel.component.azure-cosmosdb.credential-type

How the client authenticates. SHARED_ACCOUNT_KEY: with the accountKey option. AZURE_IDENTITY: with a DefaultAzureCredential of the Azure Identity library, which finds the credentials in the environment, such as environment variables, a managed identity or the Azure CLI. Not used when the cosmosAsyncClient option is set.

shared-account-key

CredentialType

camel.component.azure-cosmosdb.database-endpoint

The URI of the Azure Cosmos DB account, for example https://myaccount.documents.azure.com:443/. Required unless the cosmosAsyncClient option is set, which replaces it.

String

camel.component.azure-cosmosdb.enabled

Whether to enable auto configuration of the azure-cosmosdb component. This is enabled by default.

Boolean

camel.component.azure-cosmosdb.host-name

The name of the host, which identifies this consumer in the leases of the change feed processor. The consumers that share a lease container need different names. If not set, a random name is generated each time the change feed processor is built.

String

camel.component.azure-cosmosdb.indexing-policy

The com.azure.cosmos.models.IndexingPolicy of a container that the producer creates, with createContainer or because createContainerIfNotExists is true. If not set, the container gets the default indexing policy of Cosmos DB. The CamelAzureCosmosDbIndexingPolicy header replaces it, and the consumer does not use it. The option is a com.azure.cosmos.models.IndexingPolicy type.

IndexingPolicy

camel.component.azure-cosmosdb.item-id

The id of the item for readItem, replaceItem and deleteItem. The CamelAzureCosmosDbItemId header replaces it.

String

camel.component.azure-cosmosdb.item-partition-key

The value of the partition key of the item, as a String, for createItem, upsertItem, replaceItem, deleteItem and readItem, and of the items that readAllItems reads. If not set, the partition key value is null. The CamelAzureCosmosDbItemPartitionKey header replaces it.

String

camel.component.azure-cosmosdb.lazy-start-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

camel.component.azure-cosmosdb.lease-container-name

The name of the lease container, where the change feed processor of the consumer stores how far it has processed each range of the feed and which host processes it. The consumers that use the same lease container for the same container share the work of processing its changes. The lease container must have the partition key path /id.

camel-lease

String

camel.component.azure-cosmosdb.lease-database-name

The name of the database of the lease container. If not set, the database of the databaseName option is used.

String

camel.component.azure-cosmosdb.multiple-write-regions-enabled

Whether the client sends writes to any writable region of a geo-replicated account, in the order of preferredRegions. Has no effect unless multi-region writes are enabled on the account.

true

Boolean

camel.component.azure-cosmosdb.operation

The operation that the producer performs. The operations on a database use databaseName, and the operations on a container or its items also use containerName. The CamelAzureCosmosDbOperation header replaces this option.

listdatabases

CosmosDbOperationsDefinition

camel.component.azure-cosmosdb.preferred-regions

A comma-separated list of the preferred regions of a geo-replicated account, in order of preference, for example East US,West US. The client sends its requests to the first available region of this list.

String

camel.component.azure-cosmosdb.query

The SQL query of queryDatabases, queryContainers and queryItems, for example SELECT * FROM c WHERE c.id = '1'. The CamelAzureCosmosDbQuery header replaces it.

String

camel.component.azure-cosmosdb.query-request-options

The com.azure.cosmos.models.CosmosQueryRequestOptions of queryDatabases, listContainers, queryContainers, readAllItems and queryItems, for example to set the maximum number of items per page. The CamelAzureCosmosDbQueryRequestOptions header replaces it. The option is a com.azure.cosmos.models.CosmosQueryRequestOptions type.

CosmosQueryRequestOptions

camel.component.azure-cosmosdb.read-requests-fallback-enabled

Whether the client can send reads to the other regions of the account, for example when a region is not available. Has no effect unless the account has more than one region.

true

Boolean

camel.component.azure-cosmosdb.throughput-properties

The throughput, as a com.azure.cosmos.models.ThroughputProperties, for createDatabase, createContainer, replaceDatabaseThroughput and replaceContainerThroughput, and for the databases and containers that the create*IfNotExists options create, the lease database and lease container included. The CamelAzureCosmosDbThroughputProperties header replaces it for the producer. The option is a com.azure.cosmos.models.ThroughputProperties type.

ThroughputProperties

camel.component.azure-cosmosdb.client-telemetry-enabled

Whether to enable client telemetry. Deprecation note: Has no effect: the azure-cosmos SDK ignores this flag, as it can no longer send client telemetry to the service.

false

Boolean