committed by
Oleg Zhurakousky
parent
26f27909b8
commit
e21d2642e3
@@ -25,12 +25,24 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties(prefix = "spring.cloud.stream.rabbit.binder")
|
||||
public class RabbitBinderConfigurationProperties {
|
||||
|
||||
/**
|
||||
* Urls for management plugins; only needed for queue affinity.
|
||||
*/
|
||||
private String[] adminAddresses = new String[0];
|
||||
|
||||
/**
|
||||
* Cluster member node names; only needed for queue affinity.
|
||||
*/
|
||||
private String[] nodes = new String[0];
|
||||
|
||||
/**
|
||||
* Compression level for compressed bindings; see 'java.util.zip.Deflator'.
|
||||
*/
|
||||
private int compressionLevel;
|
||||
|
||||
/**
|
||||
* Prefix for connection names from this binder.
|
||||
*/
|
||||
private String connectionNamePrefix;
|
||||
|
||||
public String[] getAdminAddresses() {
|
||||
|
||||
@@ -102,7 +102,7 @@ spring.cloud.stream.binder.connection-name-prefix::
|
||||
A connection name prefix used to name the connection(s) created by this binder.
|
||||
The name will be this prefix followed by `#n`, where n increments each time a new connection is opened.
|
||||
+
|
||||
Defauklt: none (Spring AMQP default).
|
||||
Default: none (Spring AMQP default).
|
||||
|
||||
=== RabbitMQ Consumer Properties
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionNameStrategy;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.amqp.utils.test.TestUtils;
|
||||
@@ -96,7 +97,7 @@ public class RabbitBinderModuleTests {
|
||||
public void testParentConnectionFactoryInheritedByDefault() {
|
||||
context = new SpringApplicationBuilder(SimpleProcessor.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.run("--server.port=0");
|
||||
.run("--server.port=0", "--spring.cloud.stream.rabbit.binder.connection-name-prefix=foo");
|
||||
BinderFactory binderFactory = context.getBean(BinderFactory.class);
|
||||
Binder<?, ?, ?> binder = binderFactory.getBinder(null, MessageChannel.class);
|
||||
assertThat(binder).isInstanceOf(RabbitMessageChannelBinder.class);
|
||||
@@ -126,6 +127,11 @@ public class RabbitBinderModuleTests {
|
||||
checkPf.send(new GenericMessage<>("foo".getBytes()));
|
||||
binding.unbind();
|
||||
assertThat(TestUtils.getPropertyValue(publisherConnectionFactory, "connection.target")).isNotNull();
|
||||
|
||||
CachingConnectionFactory cf = this.context.getBean(CachingConnectionFactory.class);
|
||||
ConnectionNameStrategy cns = TestUtils.getPropertyValue(cf, "connectionNameStrategy",
|
||||
ConnectionNameStrategy.class);
|
||||
assertThat(cns.obtainNewConnectionName(cf)).isEqualTo("foo#2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,6 +172,11 @@ public class RabbitBinderModuleTests {
|
||||
.getPropertyValue("indicators");
|
||||
assertThat(healthIndicators).containsKey("rabbit");
|
||||
assertThat(healthIndicators.get("rabbit").health().getStatus()).isEqualTo(Status.UP);
|
||||
|
||||
CachingConnectionFactory cf = this.context.getBean(CachingConnectionFactory.class);
|
||||
ConnectionNameStrategy cns = TestUtils.getPropertyValue(cf, "connectionNameStrategy",
|
||||
ConnectionNameStrategy.class);
|
||||
assertThat(cns.obtainNewConnectionName(cf)).startsWith("rabbitConnectionFactory");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user