Consul
Read, write and watch keys and events in Consul, and query or register its services, nodes, health checks and sessions.
What’s inside
-
Consul component, URI syntax:
consul:apiEndpoint
Please refer to the above links for usage and configuration details.
Maven coordinates
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-consul-starter</artifactId>
</dependency> Spring Boot Auto-Configuration
The starter supports 27 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
camel.component.consul.acl-token | The ACL token that the client sends with each request to Consul, in the X-Consul-Token header. Not used when a consulClient is set: configure the token on that client instead. | String | |
camel.component.consul.action | The default action. Can be overridden by CamelConsulAction. The actions depend on the API of the endpoint: agent has CHECKS, SERVICES, MEMBERS, AGENT, REGISTER and DEREGISTER; kv has PUT, GET_VALUE, GET_VALUES, GET_KEYS, GET_SESSIONS, DELETE_KEY, DELETE_KEYS, LOCK and UNLOCK; catalog has REGISTER, DEREGISTER, LIST_DATACENTERS, LIST_NODES, LIST_SERVICES, GET_SERVICE and GET_NODE; health has CHECKS, NODE_CHECKS, SERVICE_CHECKS and SERVICE_INSTANCES; session has CREATE, DESTROY, INFO, LIST and RENEW; preparedQuery has CREATE, GET and EXECUTE; event has FIRE and LIST; coordinates has DATACENTERS and NODES; status has LEADER and PEERS. | String | |
camel.component.consul.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.consul.block-seconds | The wait time in seconds of the blocking query with which the kv and event consumers watch: Consul answers when the data changes or when the time is up, and the consumer then queries again. The event consumer also waits this long before each query, and both wait this long (at least one second) before they query again after an error. | 10 | Integer |
camel.component.consul.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.consul.configuration | The shared configuration of the endpoints that this component creates. Each endpoint gets a copy, and the endpoint options override it. The option is a org.apache.camel.component.consul.ConsulConfiguration type. | ConsulConfiguration | |
camel.component.consul.connect-timeout | The connect timeout of the HTTP client. When not set, the default of the OkHttp client applies. | Duration | |
camel.component.consul.consistency-mode | The consistency mode of the catalog and health queries: DEFAULT (the leader answers), STALE (any server answers, possibly with outdated data) or CONSISTENT (the leader first checks with a quorum that it is still the leader). The CamelConsulConsistencyMode header overrides it. | default | ConsistencyMode |
camel.component.consul.consul-client | The Consul client (org.kiwiproject.consul.Consul) to use instead of creating one. When set, the options that create the client (url, sslContextParameters, aclToken, userName, password, the timeouts and pingInstance) are not used. The option is a org.kiwiproject.consul.Consul type. | Consul | |
camel.component.consul.datacenter | The datacenter to query instead of the datacenter of the agent. Used by the catalog and health queries, the agent DEREGISTER action and the coordinates NODES action; the CamelConsulDatacenter header overrides it. | String | |
camel.component.consul.enabled | Whether to enable auto configuration of the consul component. This is enabled by default. | Boolean | |
camel.component.consul.first-index | The Consul index from which the first blocking query of the kv or event consumer waits for a change. With 0 the first query answers at once, so the consumer receives the current value of the key, or the events that Consul still keeps. The option is a java.math.BigInteger type. | BigInteger | |
camel.component.consul.key | The key (kv) or event name (event) that the consumer watches or that the producer acts on; the other APIs do not use it. In a producer, a CamelConsulKey header overrides it, unless the header still holds the key that a consul consumer received (the CamelConsulReceivedKey exchange property). | String | |
camel.component.consul.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.consul.near-node | The name of a node (or _agent for the node of the agent) from which Consul sorts the results of the catalog and health queries by estimated round trip time. The CamelConsulNearNode header overrides it. | String | |
camel.component.consul.node-meta | Comma separated node metadata filters, each as key:value, so that the catalog and health queries return only the nodes with that metadata. The CamelConsulNodeMeta header overrides it. | String | |
camel.component.consul.password | The password for HTTP basic authentication to the Consul agent. Used only together with userName. | String | |
camel.component.consul.ping-instance | Whether the Consul client pings the agent when it is created, so that creating it fails when the agent cannot be reached. The client is created when the consumer starts or when the producer handles its first message. | true | Boolean |
camel.component.consul.read-timeout | The read timeout of the HTTP client. When not set, the default of the OkHttp client applies; the Consul client extends it for the blocking queries of the consumers. | Duration | |
camel.component.consul.recursive | Whether the kv consumer watches all the keys under the key (as a prefix) instead of only the key. When one of them changes, the consumer receives a message for each key under the prefix. | false | Boolean |
camel.component.consul.ssl-context-parameters | The SSL configuration of the HTTPS connection to the Consul agent. When not set, the global SSL context parameters are used if the component enables useGlobalSslContextParameters. The option is a org.apache.camel.support.jsse.SSLContextParameters type. | SSLContextParameters | |
camel.component.consul.tags | Comma separated tags. The consul endpoints do not use this option, so setting it has no effect. | String | |
camel.component.consul.url | The URL of the Consul agent that the client connects to, such as http://localhost:8500 (the default of the Consul client when not set). Use an https URL to connect with sslContextParameters. | String | |
camel.component.consul.use-global-ssl-context-parameters | Whether to use the global SSL context parameters of the CamelContext for the endpoints that have no sslContextParameters. | false | Boolean |
camel.component.consul.user-name | The user name for HTTP basic authentication to the Consul agent. Used only together with password. | String | |
camel.component.consul.value-as-string | Whether the values of the kv API are decoded to text: the kv consumer then sets the decoded value as the body instead of the base64 encoded value, and the GET_VALUE and GET_VALUES actions return a String (a List of them) instead of Value objects. In a producer, the CamelConsulValueAsString header overrides it. | false | Boolean |
camel.component.consul.write-timeout | The write timeout of the HTTP client. When not set, the default of the OkHttp client applies. | Duration |