Integration with consul (Extension Module)

Tamaya Consul is an extension module. Refer to the extensions documentation for further details.

What functionality this module provides ?

Tamaya Consul provides different artifacts which allows use of Consul from Hashicorp as configuration backend. Basically the module supports read-only integration (as a ConsulPropertySource as well as a writing configuration changes back (based on Tamaya’s MutableConfiguration API defined by the tamaya-mutable-config extension module.


The module is based on Java 8.


To use tamaya-consul you only must add the corresponding dependency to your module:


The Functionality Provided

Tamaya Consul provides two artifacts:

  • The org.apache.tamaya.consul.ConsulPropertySource is a PropertySource with a default ordinal of 100 and the name 'consul'.

  • org.apache.tamaya.consul.ConsulPropertySource is based on org.apache.tamaya.consul.AbstractConsulPropertySource, which provides all required basic functionality to implement your own consul based property sources.

Access of consul key/value pairs is through the normal Tamaya API.

The ConsulPropertySource

The ConsulPropertySource allows the consul servers to be used as configuration backends. It provides:

  • a Consul based property source implementation.

  • configurable caching of key/values accessed (Consul does not provide reading all values out).

  • configuring a optional key prefix for defining a namespace for Tamaya configuration within the consul key/value store.

  • ConsulPropertySource reads the tamaya.consul.urls system and environment property to evaluate the consul servers to be used (comma separated). The API just performs a Round-Robin through the list of configured servers. Without any configuration is used. If no connection to any consul server can be established a warning will be logged, but deployment will not fail.

  • The ConsulPropertySource finally also allows the values read from the consul cluster to be mapped with a prefix. This allows to let all values stored in consul have their own namespace. E.g. the Tamaya key a.b is mapped to foo.a.b, when the prefix is set to foo.. The prefix can be activated by setting the tamaya.consul.prefix system or environment property.

The AbstractConsulPropertySource

The AbstractConsulPropertySource provides all features from ConsulPropertySource but does not define how the property source is exactly configured, so you have full control.