Add support for RabbitMQ's addressShuffleMode property

See gh-23091
This commit is contained in:
Jonghan Kim 2020-08-26 20:08:46 +09:00 committed by Stephane Nicoll
parent 3748b234ed
commit 4b77e2e205
2 changed files with 17 additions and 0 deletions

View File

@ -83,6 +83,7 @@ import org.springframework.context.annotation.Import;
* @author Gary Russell
* @author Phillip Webb
* @author Artsiom Yudovin
* @author Jonghan Kim
* @since 1.0.0
*/
@Configuration(proxyBeanMethods = false)
@ -105,6 +106,7 @@ public class RabbitAutoConfiguration {
.getObject());
PropertyMapper map = PropertyMapper.get();
map.from(properties::determineAddresses).to(factory::setAddresses);
map.from(properties::getAddressShuffleMode).whenNonNull().to(factory::setAddressShuffleMode);
map.from(properties::isPublisherReturns).to(factory::setPublisherReturns);
map.from(properties::getPublisherConfirmType).whenNonNull().to(factory::setPublisherConfirmType);
RabbitProperties.Cache.Channel channel = properties.getCache().getChannel();

View File

@ -23,6 +23,7 @@ import java.util.List;
import java.util.Optional;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.AddressShuffleMode;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.ConfirmType;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -41,6 +42,7 @@ import org.springframework.util.StringUtils;
* @author Gary Russell
* @author Artsiom Yudovin
* @author Franjo Zilic
* @author Jonghan Kim
* @since 1.0.0
*/
@ConfigurationProperties(prefix = "spring.rabbitmq")
@ -87,6 +89,11 @@ public class RabbitProperties {
*/
private String addresses;
/**
* Shuffling mode for connecting host.
*/
private AddressShuffleMode addressShuffleMode;
/**
* Requested heartbeat timeout; zero for none. If a duration suffix is not specified,
* seconds will be used.
@ -282,6 +289,14 @@ public class RabbitProperties {
this.virtualHost = "".equals(virtualHost) ? "/" : virtualHost;
}
public AddressShuffleMode getAddressShuffleMode() {
return this.addressShuffleMode;
}
public void setAddressShuffleMode(AddressShuffleMode addressShuffleMode) {
this.addressShuffleMode = addressShuffleMode;
}
public Duration getRequestedHeartbeat() {
return this.requestedHeartbeat;
}