Skip to content

Commit 4b77e2e

Browse files
01045972746snicoll
authored andcommitted
Add support for RabbitMQ's addressShuffleMode property
See gh-23091
1 parent 3748b23 commit 4b77e2e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
* @author Gary Russell
8484
* @author Phillip Webb
8585
* @author Artsiom Yudovin
86+
* @author Jonghan Kim
8687
* @since 1.0.0
8788
*/
8889
@Configuration(proxyBeanMethods = false)
@@ -105,6 +106,7 @@ public CachingConnectionFactory rabbitConnectionFactory(RabbitProperties propert
105106
.getObject());
106107
PropertyMapper map = PropertyMapper.get();
107108
map.from(properties::determineAddresses).to(factory::setAddresses);
109+
map.from(properties::getAddressShuffleMode).whenNonNull().to(factory::setAddressShuffleMode);
108110
map.from(properties::isPublisherReturns).to(factory::setPublisherReturns);
109111
map.from(properties::getPublisherConfirmType).whenNonNull().to(factory::setPublisherConfirmType);
110112
RabbitProperties.Cache.Channel channel = properties.getCache().getChannel();

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Optional;
2424

2525
import org.springframework.amqp.core.AcknowledgeMode;
26+
import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.AddressShuffleMode;
2627
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode;
2728
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.ConfirmType;
2829
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -41,6 +42,7 @@
4142
* @author Gary Russell
4243
* @author Artsiom Yudovin
4344
* @author Franjo Zilic
45+
* @author Jonghan Kim
4446
* @since 1.0.0
4547
*/
4648
@ConfigurationProperties(prefix = "spring.rabbitmq")
@@ -87,6 +89,11 @@ public class RabbitProperties {
8789
*/
8890
private String addresses;
8991

92+
/**
93+
* Shuffling mode for connecting host.
94+
*/
95+
private AddressShuffleMode addressShuffleMode;
96+
9097
/**
9198
* Requested heartbeat timeout; zero for none. If a duration suffix is not specified,
9299
* seconds will be used.
@@ -282,6 +289,14 @@ public void setVirtualHost(String virtualHost) {
282289
this.virtualHost = "".equals(virtualHost) ? "/" : virtualHost;
283290
}
284291

292+
public AddressShuffleMode getAddressShuffleMode() {
293+
return this.addressShuffleMode;
294+
}
295+
296+
public void setAddressShuffleMode(AddressShuffleMode addressShuffleMode) {
297+
this.addressShuffleMode = addressShuffleMode;
298+
}
299+
285300
public Duration getRequestedHeartbeat() {
286301
return this.requestedHeartbeat;
287302
}

0 commit comments

Comments
 (0)