Polish "Add support for RabbitMQ's addressShuffleMode property"
See gh-23091
This commit is contained in:
@@ -83,7 +83,6 @@ 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)
|
||||
|
||||
@@ -42,7 +42,6 @@ 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")
|
||||
@@ -90,9 +89,9 @@ public class RabbitProperties {
|
||||
private String addresses;
|
||||
|
||||
/**
|
||||
* Shuffling mode for connecting host.
|
||||
* Mode used to shuffle configured addresses.
|
||||
*/
|
||||
private AddressShuffleMode addressShuffleMode;
|
||||
private AddressShuffleMode addressShuffleMode = AddressShuffleMode.NONE;
|
||||
|
||||
/**
|
||||
* Requested heartbeat timeout; zero for none. If a duration suffix is not specified,
|
||||
|
||||
@@ -1538,6 +1538,10 @@
|
||||
"name": "spring.r2dbc.pool.validation-depth",
|
||||
"defaultValue": "local"
|
||||
},
|
||||
{
|
||||
"name": "spring.rabbitmq.address-shuffle-mode",
|
||||
"defaultValue": "none"
|
||||
},
|
||||
{
|
||||
"name": "spring.rabbitmq.cache.connection.mode",
|
||||
"defaultValue": "channel"
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.springframework.amqp.rabbit.config.AbstractRabbitListenerContainerFac
|
||||
import org.springframework.amqp.rabbit.config.DirectRabbitListenerContainerFactory;
|
||||
import org.springframework.amqp.rabbit.config.RabbitListenerConfigUtils;
|
||||
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
||||
import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.AddressShuffleMode;
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
@@ -137,12 +138,15 @@ class RabbitAutoConfigurationTests {
|
||||
void testConnectionFactoryWithOverrides() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
||||
.withPropertyValues("spring.rabbitmq.host:remote-server", "spring.rabbitmq.port:9000",
|
||||
"spring.rabbitmq.username:alice", "spring.rabbitmq.password:secret",
|
||||
"spring.rabbitmq.virtual_host:/vhost", "spring.rabbitmq.connection-timeout:123")
|
||||
"spring.rabbitmq.address-shuffle-mode=random", "spring.rabbitmq.username:alice",
|
||||
"spring.rabbitmq.password:secret", "spring.rabbitmq.virtual_host:/vhost",
|
||||
"spring.rabbitmq.connection-timeout:123")
|
||||
.run((context) -> {
|
||||
CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class);
|
||||
assertThat(connectionFactory.getHost()).isEqualTo("remote-server");
|
||||
assertThat(connectionFactory.getPort()).isEqualTo(9000);
|
||||
assertThat(connectionFactory).hasFieldOrPropertyWithValue("addressShuffleMode",
|
||||
AddressShuffleMode.RANDOM);
|
||||
assertThat(connectionFactory.getVirtualHost()).isEqualTo("/vhost");
|
||||
com.rabbitmq.client.ConnectionFactory rcf = connectionFactory.getRabbitConnectionFactory();
|
||||
assertThat(rcf.getConnectionTimeout()).isEqualTo(123);
|
||||
|
||||
Reference in New Issue
Block a user