Production-ready Spring Boot starters that make it easy to configure and consume multiple Redis, RabbitMQ, and InfluxDB 2.x connections in a single application.
The starters wrap Spring Boot auto-configuration patterns and expose a consistent properties model under the spring.multi-sources.*
namespace. Each data source you define results in a dedicated set of Spring beans so you can connect to many back-ends without duplicating configuration code.
-
Manage multiple Redis, RabbitMQ, and InfluxDB 2.x connections using pure configuration.
-
Deterministic bean naming (
<sourceName><ClassSimpleName>
) keeps injection explicit and type-safe. -
Built on Spring Boot 3.5.x and Java 17 with familiar
@ConfigurationProperties
support.
-
Java 17+
-
Spring Boot 3.5.x (pulled in via the parent BOM)
-
One or more of the supported back-end clients (Lettuce or Jedis for Redis, Spring AMQP, InfluxDB Java client)
Module | Maven coordinates | Purpose |
---|---|---|
|
|
Configure multiple Redis data sources backed by Lettuce or Jedis. |
|
|
Manage multiple RabbitMQ connections and messaging infrastructure. |
|
|
Connect to multiple InfluxDB 2.x organizations/buckets. |
-
Add the starter(s) you need to your project.
-
Configure
spring.multi-sources.<type>
properties for each connection, including a mandatoryprimary-key
. -
Inject the generated beans using
@Qualifier
and the<sourceName><ClassSimpleName>
naming scheme.
<dependency>
<groupId>com.childrengreens</groupId>
<artifactId>redis-multi-source-spring-boot-starter</artifactId>
<version>2.6</version>
</dependency>
Need Jedis instead of Lettuce? Add the client to your project:
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
At minimum specify a primary-key
and one or more entries under sources
. Each source can target standalone, sentinel, or cluster deployments.
# required default source
spring.multi-sources.redis.primary-key=cn
# standalone example
spring.multi-sources.redis.sources.cn.host=127.0.0.1
spring.multi-sources.redis.sources.cn.port=6379
spring.multi-sources.redis.sources.cn.password=changeme
# sentinel example
spring.multi-sources.redis.sources.hk.sentinel.master=hk-redis-master
spring.multi-sources.redis.sources.hk.sentinel.nodes[0]=192.168.1.1:26379
spring.multi-sources.redis.sources.hk.sentinel.nodes[1]=192.168.1.2:26379
spring.multi-sources.redis.sources.hk.database=0
spring.multi-sources.redis.sources.hk.client-type=jedis
spring.multi-sources.redis.sources.hk.password=changeme
spring.multi-sources.redis.sources.hk.lettuce.pool.enabled=true
# cluster example
spring.multi-sources.redis.sources.us.cluster.nodes[0]=127.0.0.1:6379
spring.multi-sources.redis.sources.us.cluster.nodes[1]=127.0.0.1:6380
spring.multi-sources.redis.sources.us.cluster.nodes[2]=127.0.0.1:6381
spring.multi-sources.redis.sources.us.cluster.max-redirects=3
spring.multi-sources.redis.sources.us.password=changeme
spring:
multi-sources:
redis:
primary-key: cn
sources:
cn:
host: 127.0.0.1
port: 6379
password: changeme
hk:
client-type: jedis
password: changeme
sentinel:
master: hk-redis-master
nodes:
- 192.168.1.1:26379
- 192.168.1.2:26379
database: 0
lettuce:
pool:
enabled: true
us:
password: changeme
cluster:
nodes:
- 127.0.0.1:6379
- 127.0.0.1:6380
- 127.0.0.1:6381
max-redirects: 3
The starter registers LettuceConnectionFactory
or JedisConnectionFactory
, RedisTemplate
, and StringRedisTemplate
per source.
spring.multi-sources.rabbitmq.primary-key=cn
spring.multi-sources.rabbitmq.sources.cn.host=192.168.1.1
spring.multi-sources.rabbitmq.sources.cn.port=5672
spring.multi-sources.rabbitmq.sources.cn.username=guest
spring.multi-sources.rabbitmq.sources.cn.password=guest
spring.multi-sources.rabbitmq.sources.cn.virtual-host=/
spring.multi-sources.rabbitmq.sources.hk.host=192.168.1.2
spring.multi-sources.rabbitmq.sources.hk.port=5672
spring.multi-sources.rabbitmq.sources.hk.username=guest
spring.multi-sources.rabbitmq.sources.hk.password=guest
spring.multi-sources.rabbitmq.sources.hk.virtual-host=/
spring:
multi-sources:
rabbitmq:
primary-key: cn
sources:
cn:
host: 192.168.1.1
port: 5672
username: guest
password: guest
virtual-host: /
hk:
host: 192.168.1.2
port: 5672
username: guest
password: guest
virtual-host: /
The starter provisions CachingConnectionFactory
, RabbitTemplate
, RabbitMessagingTemplate
, and SimpleRabbitListenerContainerFactory
beans per source.
spring.multi-sources.influx.primary-key=cn
spring.multi-sources.influx.sources.cn.url=http://127.0.0.1:8086/
spring.multi-sources.influx.sources.cn.token=CHANGEME
spring.multi-sources.influx.sources.cn.org=cn-market-data
spring.multi-sources.influx.sources.cn.bucket=cn-data
spring.multi-sources.influx.sources.hk.url=http://127.0.0.2:8086/
spring.multi-sources.influx.sources.hk.token=CHANGEME
spring.multi-sources.influx.sources.hk.org=hk-market-data
spring.multi-sources.influx.sources.hk.bucket=hk-data
spring:
multi-sources:
influx:
primary-key: cn
sources:
cn:
url: http://127.0.0.1:8086/
token: CHANGEME
org: cn-market-data
bucket: cn-data
hk:
url: http://127.0.0.2:8086/
token: CHANGEME
org: hk-market-data
bucket: hk-data
Each configured source exposes an InfluxDBClient
bean.
Beans follow the <sourceName><ClassSimpleName>
pattern. A source named cn
produces beans such as cnStringRedisTemplate
, cnCachingConnectionFactory
, or cnInfluxDBClient
. Inject them explicitly with @Qualifier
:
@Autowired
@Qualifier("hkRedisTemplate")
private RedisTemplate<String, Object> hkRedisTemplate;
@Autowired
@Qualifier("usLettuceConnectionFactory")
private RedisConnectionFactory usConnectionFactory;
@Autowired
@Qualifier("cnCachingConnectionFactory")
private CachingConnectionFactory cnRabbitConnectionFactory;
@Autowired
@Qualifier("hkInfluxDBClient")
private InfluxDBClient hkInfluxClient;
Run mvn validate
to apply license headers and mvn clean install
to build all modules. Individual modules can be built with mvn -pl <module> -am package
.
Spring Boot Multi Source Starters are released under the Apache 2.0 license.