Skip to content

Commit 6b477b7

Browse files
Updating README.adoc for RabbitMQ Multi Data Sources
1 parent a3ab71e commit 6b477b7

File tree

2 files changed

+83
-2
lines changed

2 files changed

+83
-2
lines changed

README.adoc

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To use Redis multi-data sources, you need to add the Redis Multi Sources Spring
1717
<dependency>
1818
<groupId>com.childrengreens</groupId>
1919
<artifactId>redis-multi-source-spring-boot-starter</artifactId>
20-
<version>2.0</version>
20+
<version>2.1</version>
2121
</dependency>
2222
----
2323
Add the following configuration to your properties file.
@@ -113,6 +113,87 @@ private RedisConnectionFactory redisConnectionFactory;
113113
114114
----
115115

116+
117+
=== RabbitMQ Multi Data Sources
118+
To use RabbitMQ multi-data sources, you need to add the AMQP Multi Sources Spring Boot Starter dependency to your project.
119+
[source,xml]
120+
----
121+
<dependency>
122+
<groupId>com.childrengreens</groupId>
123+
<artifactId>amqp-multi-source-spring-boot-starter</artifactId>
124+
<version>2.1</version>
125+
</dependency>
126+
----
127+
Add the following configuration to your properties file.
128+
[source,properties]
129+
----
130+
# set the primary-key data source (must)
131+
spring.multi-sources.rabbitmq.primary-key=cn
132+
133+
# cn data source
134+
spring.multi-sources.rabbitmq.sources.cn.port=5672
135+
spring.multi-sources.rabbitmq.sources.cn.host=192.168.1.1
136+
spring.multi-sources.rabbitmq.sources.cn.username=guest
137+
spring.multi-sources.rabbitmq.sources.cn.password=guest
138+
spring.multi-sources.rabbitmq.sources.cn.virtual-host=/
139+
140+
# hk data source
141+
spring.multi-sources.rabbitmq.sources.hk.port=5672
142+
spring.multi-sources.rabbitmq.sources.hk.host=192.168.1.2
143+
spring.multi-sources.rabbitmq.sources.hk.username=guest
144+
spring.multi-sources.rabbitmq.sources.hk.password=guest
145+
spring.multi-sources.rabbitmq.sources.hk.virtual-host=/
146+
147+
----
148+
149+
150+
[source,yml]
151+
----
152+
# set the primary-key data source (must)
153+
spring:
154+
multi-sources:
155+
rabbitmq:
156+
primary-key: cn
157+
158+
# cn data source
159+
sources:
160+
cn:
161+
port: 5672
162+
host: 192.168.1.1
163+
username: guest
164+
password: guest
165+
virtual-host: /
166+
167+
# hk data source
168+
hk:
169+
port: 5672
170+
host: 192.168.1.2
171+
username: guest
172+
password: guest
173+
virtual-host: /
174+
----
175+
=== RabbitMQ Multi Source Runtime
176+
AMQP Multi Sources Spring Boot Starter will create multiple sets of `CachingConnectionFactory`, `SimpleRabbitListenerContainerFactory`, `RabbitTemplate`, and `RabbitMessagingTemplate` beans based on the configuration and register them in the Spring container.
177+
178+
The naming convention for the bean names is: `sourceName` + `className`. Therefore, the usage is as follows:
179+
[source,java]
180+
----
181+
@Autowired
182+
@Qualifier("cnCachingConnectionFactory")
183+
private CachingConnectionFactory cachingConnectionFactory;
184+
185+
186+
@Autowired
187+
@Qualifier("hkRabbitTemplate")
188+
private RabbitTemplate rabbitTemplate;
189+
190+
191+
@Autowired
192+
@Qualifier("hkSimpleRabbitListenerContainerFactory")
193+
private SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory;
194+
195+
----
196+
116197
== License
117198

118199
Spring Boot is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].

amqp-multi-source-spring-boot-starter/src/main/java/com/childrengreens/multi/source/RabbitMultiSourcesAnnotationDrivenRegistrar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void registerBeanDefinitionsForSource(String name, RabbitProperties source, Bean
8181
});
8282

8383

84-
// register DirectRabbitListenerContainerFactoryConfigurer
84+
// register SimpleRabbitListenerContainerFactory
8585
registerBeanDefinition(registry,
8686
SimpleRabbitListenerContainerFactory.class,
8787
generateBeanName(SimpleRabbitListenerContainerFactory.class, name),

0 commit comments

Comments
 (0)