Config Manager is a lightweight library designed to store application properties and configurations in memory efficiently.
The library supports various data sources, including:
- File-based configurations (e.g.,
.properties
,.yml
) - Relational databases (e.g., Oracle, MySQL, PostgreSQL, SQL Server, etc.)
- NoSQL databases (e.g., MongoDB, Cassandra)
- Cache servers (e.g., Hazelcast, Redis)
It offers flexible loading strategies:
- Pull-based policies, such as eager or lazy loading, with options for triggers and scheduled updates.
- Push-based policies, using pub-sub patterns like Hazelcast topics, Redis channels, or native Java queues.
Config Manager is a lightweight, high-performance, multi-data-source-supported library for dynamic configuration management.
Commons Lang Version | Java Version |
---|---|
3.X.X | 1.8 >= |
4.X.X | 17 |
Artifact | Version |
---|---|
config-manager-spring | |
config-manager-spring |
JDK 17
implementation 'com.inomera.telco.commons:config-manager-spring:4.0.0'
JDK 8+
implementation 'com.inomera.telco.commons:config-manager-spring:3.4.0'
config-manager:
enabled: true
source: properties
reload:
enabled: true
trigger: cron
cron-expression: '0/2 * * * * ?'
properties:
property-files: classpath:settings.properties
JDK 17
implementation 'com.inomera.telco.commons:config-manager-spring:4.0.0'
// Other dependencies for related jdbc driver
JDK 8+
implementation 'com.inomera.telco.commons:config-manager-spring:3.4.0'
// Other dependencies for related jdbc driver
config-manager:
enabled: true
source: jdbc
reload:
enabled: true
trigger: periodical
period: 2
period-unit: seconds
jdbc:
driver-class-name: org.h2.Driver
url: 'jdbc:h2:mem:testdb;MODE=Oracle'
username: sa
password: password
select-sql: SELECT KEY, VALUE FROM APP_SETTINGS
JDK 17
implementation 'com.inomera.telco.commons:config-manager-spring:4.0.0'
compileOnly "org.mongodb:mongodb-driver-sync:4.8.1"
compileOnly "org.mongodb:mongodb-driver-core:4.8.1"
JDK 8+
implementation 'com.inomera.telco.commons:config-manager-spring:3.4.0'
implementation 'org.mongodb:mongodb-driver:3.11.2'
config-manager:
enabled: true
source: mongo
reload:
enabled: true
trigger: periodical
period: 5
period-unit: seconds
mongo:
servers:
- host: 127.0.0.1
port: 27017
query:
application: application
label: master
profile: default
db-name: testDB
value-field-name: value
key-field-name: key
collection: testCollection
JDK 17
implementation 'com.inomera.telco.commons:config-manager-spring:4.0.0'
implementation 'com.datastax.cassandra:cassandra-driver-core:3.6.0'
implementation 'com.datastax.cassandra:cassandra-driver-mapping:3.6.0'
implementation 'com.datastax.cassandra:cassandra-driver-extras:3.6.0'
JDK 8+
implementation 'com.inomera.telco.commons:config-manager-spring:3.4.0'
implementation 'com.datastax.cassandra:cassandra-driver-core:3.6.0'
implementation 'com.datastax.cassandra:cassandra-driver-mapping:3.6.0'
implementation 'com.datastax.cassandra:cassandra-driver-extras:3.6.0'
config-manager:
enabled: true
source: cassandra
reload:
enabled: true
trigger: periodical
period: 5
period-unit: seconds
cassandra:
nodes:
- host: localhost
port: 9042
username: cassandra
password: cassandra
select-sql: select key, value from example_cassandra.app_settings where application = 'application'
To use redis as a data source, the following dependencies must be added.
JDK 17
implementation 'com.inomera.telco.commons:config-manager-spring:4.0.0'
implementation 'org.redisson:redisson:3.23.4'
JDK 8+
implementation 'com.inomera.telco.commons:config-manager-spring:3.4.0'
implementation 'org.redisson:redisson:3.23.4'
You need to specify config-manager related settings in your application.yml
file.
The config-manager.redis.redisson.map-key
value must be a hash name that holds a collection of application settings
stored in redis.
Below is an example of singleServerConfig. You can specify the Redisson
settings config-manager.redis.redisson.config
in YAML format. For more information
see https://github.com/redisson/redisson/wiki/2.-Configuration#262-single-instance-yaml-config-format.
config-manager:
enabled: true
source: redis
reload:
enabled: true
trigger: periodical
period: 5
period-unit: seconds
redis:
redisson:
map-key: example-redis-dev
config: |
singleServerConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
password: null
username: null
subscriptionsPerConnection: 5
clientName: null
address: "redis://127.0.0.1:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 10
connectionPoolSize: 64
database: 0
dnsMonitoringInterval: 5000
threads: 2
nettyThreads: 4
codec: !<org.redisson.codec.Kryo5Codec> {}
transportMode: "NIO"
JDK 17
implementation 'com.inomera.telco.commons:config-manager-spring:4.0.0'
implementation 'org.jasypt:jasypt:1.9.3'
JDK 8+
implementation 'com.inomera.telco.commons:config-manager-spring:3.4.0'
implementation 'org.jasypt:jasypt:1.9.3'
config-manager:
enabled: true
source: properties
reload:
enabled: true
trigger: cron
cron-expression: '0/2 * * * * ?'
properties:
property-files: classpath:settings.properties
encryption:
enabled: true
secret-key: '12345678901234567890123456789012'
To publish a version to maven repository, you should edit your local gradle.properties file.
The file is: /path-to-user-home/.gradle/gradle.properties
For example: ~/.gradle/gradle.properties
Add credentials for nexus repository to gradle.properties
file.
Example gradle.properties
file:
telcoTeamUsername=********
telcoTeamPassword=************************
Then execute gradle
publish
task on the project.
For example, to publish the project config-manager-core
, config-manager-spring
you need to execute the following command in project root:
gradle :config-manager-spring:publish
gradle :config-manager-core:publish
The repository will not allow you to publish the same version twice. You need to change version of the artifact every time you want to publish.
You can change version in build.gradle
file of the sub-project.
build.gradle > publishing > publications > mavenJava > version
Please change the version wisely.
- Upgrade Spring Boot 3.1.1 and JDK 17 (@atakan)
- Add Redis support (@fatihbozik)
- Adds new converter methods for the following basic types (@sedran)
- getDoubleProperty
- getFloatProperty
- getJsonSetProperty
- getEnumValue
- getEnumList
- getEnumSet
Add configuration post processor support and encryption (@sedran)