이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 42. Etcd


Etcd Component

Etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines.
Maven users will need to add the following dependency to their pom.xml for this component.
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-etcd</artifactId>
    <!-- use the same version as your Camel core version -->
    <version>x.y.z</version>
</dependency>
Copy to Clipboard Toggle word wrap

URI format

etcd:namespace[/path][?options]
Copy to Clipboard Toggle word wrap
Where namespace represents the etcd context to which the etcd-component should operate and path is an optional attribute to define which node is being impacted.
Supported namespaces are:
  • keys
  • watch
  • stats

Options

Expand
Name
Default Value
Description
uris
Defines the URIs the component should connect to.
sslContextParameters null To use a custom org.apache.camel.util.jsse.SSLContextParameters. See Using the JSSE Configuration Utility
userName null The user name to use for basic authentication
password null The password to use for basic authentication
sendEmptyExchangeOnTimeout false To send an empty message in case of timeout watching for a key (consumer only)
recursive false To apply an action recursively
timeToLive null To set the lifespan of a key in milliseconds
timeout null To set the maximum time an action could take to complete.

Headers

Expand
NameTypeDescription
CamelEtcdAction java.lang.String The action to perform, supported values are set, delete, deleteDir, get
CamelEtcdNamespace java.lang.String
The etcd context an exchange was generated/processed from
CamelEtcdPath java.lang.String
For keys namespace, it is used to determine the node subject the the action, if not set the path from URI endpoint is used. For stats and watch namespaces it contains the path of the node beign processed
CamelEtcdTimeout java.lang.Long To set the maximum time an action could take to complete. If not present, the timeout option is taken into account
CamelEtcdTtl java.lang.Integer To set the lifespan of a key in milliseconds. If not present, the timeToLive option is taken into account
CamelEtcdRecursive java.lang.Boolean To apply an action recursively. If not present, the recursive option is taken into account.

Keys namespace example:

CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
    public void configure() {
       from("direct:keys-set")
            .to("etcd:keys")
                .to("log:camel-etcd?level=INFO");
    }
});

Map<String, Object> headers = new HashMap<>();
headers.put(EtcdConstants.ETCD_ACTION, EtcdConstants.ETCD_KEYS_ACTION_SET);
headers.put(EtcdConstants.ETCD_PATH, "/camel/etcd/myKey");
 
ProducerTemplate template = context.createProducerTemplate();
template.sendBodyAndHeaders("direct:keys-set", "camel-etcd", headers);
Copy to Clipboard Toggle word wrap

Stats namespace example:

CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
    public void configure() {
       from("etcd:stats/leader?consumer.delay=50&consumer.initialDelay=0")
           .to("log:etcd-leader-stats?level=INFO");
       from("etcd:stats/self?consumer.delay=50&consumer.initialDelay=0")
           .to("log:etcd-self-stats?level=INFO");
       from("etcd:stats/store?consumer.delay=50&consumer.initialDelay=0")
           .to("log:etcd-store-stats?level=INFO");
    }
});
Copy to Clipboard Toggle word wrap

Watch namespace example:

CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
    public void configure() {
       from("etcd:watch/recursive?recursive=true")
        .marshall().json()
        .to("log:etcd-event?level=INFO")
    }
});
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat