Etcd v3
Since Camel 3.19
Both producer and consumer are supported
The Etcd v3 component allows you to work with Etcd, a distributed reliable key-value store.
Maven users will need to add the following dependency to their pom.xml
for this component:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-etcd3</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
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 Etcd v3 component supports 25 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
Component configuration. | Etcd3Configuration | ||
Configure etcd server endpoints using the IPNameResolver. Multiple endpoints can be separated by comma. | String | ||
Configure the charset to use for the keys. | UTF-8 | String | |
Configure the namespace of keys used. / will be treated as no namespace. | String | ||
To apply an action on all the key-value pairs whose key that starts with the target path. | false | boolean | |
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 | |
The index to watch from. | 0 | long | |
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 | |
Configure the charset to use for the values. | UTF-8 | String | |
Configure the headers to be added to auth request headers. | Map | ||
Configure the authority used to authenticate connections to servers. | String | ||
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 | |
Configure the connection timeout. | Duration | ||
Configure the headers to be added to http request headers. | Map | ||
Configure the interval for gRPC keepalives. The current minimum allowed by gRPC is 10 seconds. | 30 seconds | Duration | |
Configure the timeout for gRPC keepalives. | 10 seconds | Duration | |
Configure etcd load balancer policy. | String | ||
Configure the maximum message size allowed for a single gRPC frame. | Integer | ||
Configure the delay between retries in milliseconds. | 500 | long | |
Configure the max backing off delay between retries in milliseconds. | 2500 | long | |
Configure the retries max duration. | Duration | ||
The path to look for service discovery. | /services/ | String | |
Configure etcd auth password. | String | ||
Configure SSL/TLS context to use instead of the system default. | SslContext | ||
Configure etcd auth user. | String |
Endpoint Options
The Etcd v3 endpoint is configured using URI syntax:
etcd3:path
With the following path and query parameters:
Query Parameters (25 parameters)
Name | Description | Default | Type |
---|---|---|---|
Configure etcd server endpoints using the IPNameResolver. Multiple endpoints can be separated by comma. | String | ||
Configure the charset to use for the keys. | UTF-8 | String | |
Configure the namespace of keys used. / will be treated as no namespace. | String | ||
To apply an action on all the key-value pairs whose key that starts with the target path. | false | boolean | |
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 | |
To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | ExceptionHandler | ||
Sets the exchange pattern when the consumer creates an exchange. Enum values:
| ExchangePattern | ||
The index to watch from. | 0 | long | |
Configure the charset to use for the values. | UTF-8 | String | |
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 | |
Configure the headers to be added to auth request headers. | Map | ||
Configure the authority used to authenticate connections to servers. | String | ||
Configure the connection timeout. | Duration | ||
Configure the headers to be added to http request headers. | Map | ||
Configure the interval for gRPC keepalives. The current minimum allowed by gRPC is 10 seconds. | 30 seconds | Duration | |
Configure the timeout for gRPC keepalives. | 10 seconds | Duration | |
Configure etcd load balancer policy. | String | ||
Configure the maximum message size allowed for a single gRPC frame. | Integer | ||
Configure the delay between retries in milliseconds. | 500 | long | |
Configure the max backing off delay between retries in milliseconds. | 2500 | long | |
Configure the retries max duration. | Duration | ||
The path to look for service discovery. | /services/ | String | |
Configure etcd auth password. | String | ||
Configure SSL/TLS context to use instead of the system default. | SslContext | ||
Configure etcd auth user. | String |
Message Headers
The Etcd v3 component supports 5 message header(s), which is/are listed below:
Name | Description | Default | Type |
---|---|---|---|
Constant: | The action to perform. Supported values: set get delete. | String | |
Constant: | The target path. | String | |
Constant: | To apply an action on all the key-value pairs whose key that starts with the target path. | Boolean | |
CamelEtcdKeyCharset (producer) Constant: | The charset to use for the keys. | String | |
CamelEtcdValueCharset (producer) Constant: | The charset to use for the values. | String |
Producer Operations (Since 3.20)
Apache Camel supports different etcd operations.
To define the operation, set the exchange header with a key of CamelEtcdAction
and a value set to one of the following:
operation | input message body | output message body | description |
---|---|---|---|
set | String value of the key-value pair to put |
| Puts a new key-value pair into etcd where the option |
get | None |
| Retrieve the key-value pair(s) that match with the key corresponding to the option |
delete | None |
| Delete the key-value pair(s) that match with the key corresponding to the option == Consumer (Since 3.20) The consumer of the etcd components allows watching changes on the matching key-value pair(s). One exchange is created per event with the header You can set the key charset by setting the exchange header with the key By default, the consumer receives only the latest changes, but it is also possible to start watching events from a specific revision by setting the option == AggregationRepository The Etcd v3 component provides an == RoutePolicy (Since 3.20) The Etcd v3 component provides a |
Spring Boot Auto-Configuration
When using etcd3 with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-etcd3-starter</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
The component supports 26 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
Configure the headers to be added to auth request headers. | Map | ||
Configure the authority used to authenticate connections to servers. | String | ||
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 | |
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 | |
Component configuration. The option is a org.apache.camel.component.etcd3.Etcd3Configuration type. | Etcd3Configuration | ||
Configure the connection timeout. | Duration | ||
Whether to enable auto configuration of the etcd3 component. This is enabled by default. | Boolean | ||
Configure etcd server endpoints using the IPNameResolver. Multiple endpoints can be separated by comma. | String | ||
The index to watch from. | 0 | Long | |
Configure the headers to be added to http request headers. | Map | ||
Configure the interval for gRPC keepalives. The current minimum allowed by gRPC is 10 seconds. | Duration | ||
Configure the timeout for gRPC keepalives. | Duration | ||
Configure the charset to use for the keys. | UTF-8 | String | |
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 | |
Configure etcd load balancer policy. | String | ||
Configure the maximum message size allowed for a single gRPC frame. | Integer | ||
Configure the namespace of keys used. / will be treated as no namespace. | String | ||
Configure etcd auth password. | String | ||
To apply an action on all the key-value pairs whose key that starts with the target path. | false | Boolean | |
Configure the delay between retries in milliseconds. | 500 | Long | |
Configure the max backing off delay between retries in milliseconds. | 2500 | Long | |
Configure the retries max duration. | Duration | ||
The path to look for service discovery. | /services/ | String | |
Configure SSL/TLS context to use instead of the system default. The option is a io.netty.handler.ssl.SslContext type. | SslContext | ||
Configure etcd auth user. | String | ||
Configure the charset to use for the values. | UTF-8 | String |