Browse Source

Use separate RabbitAdmin to declare queues and exchanges

Fixes gh-259
pull/6/head
Dave Syer 10 years ago
parent
commit
cc2159f77b
  1. 6
      spring-cloud-netflix-hystrix-amqp/pom.xml
  2. 6
      spring-cloud-netflix-hystrix-amqp/src/main/java/org/springframework/cloud/netflix/hystrix/amqp/HystrixStreamAutoConfiguration.java
  3. 9
      spring-cloud-netflix-turbine-amqp/pom.xml
  4. 6
      spring-cloud-netflix-turbine-amqp/src/main/java/org/springframework/cloud/netflix/turbine/amqp/TurbineAmqpAutoConfiguration.java

6
spring-cloud-netflix-hystrix-amqp/pom.xml

@ -28,10 +28,6 @@ @@ -28,10 +28,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-core</artifactId>
@ -39,12 +35,10 @@ @@ -39,12 +35,10 @@
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-amqp</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>

6
spring-cloud-netflix-hystrix-amqp/src/main/java/org/springframework/cloud/netflix/hystrix/amqp/HystrixStreamAutoConfiguration.java

@ -18,6 +18,7 @@ package org.springframework.cloud.netflix.hystrix.amqp; @@ -18,6 +18,7 @@ package org.springframework.cloud.netflix.hystrix.amqp;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
@ -111,7 +112,7 @@ public class HystrixStreamAutoConfiguration { @@ -111,7 +112,7 @@ public class HystrixStreamAutoConfiguration {
// TODO: set content type
/*
* .enrichHeaders(new ComponentConfigurer<HeaderEnricherSpec>() {
*
*
* @Override public void configure(HeaderEnricherSpec spec) {
* spec.header("content-type", "application/json", true); } })
*/
@ -121,6 +122,9 @@ public class HystrixStreamAutoConfiguration { @@ -121,6 +122,9 @@ public class HystrixStreamAutoConfiguration {
private ConnectionFactory connectionFactory() {
if (this.hystrixConnectionFactory != null) {
RabbitAdmin amqpAdmin = new RabbitAdmin(this.hystrixConnectionFactory);
hystrixStreamExchange().setAdminsThatShouldDeclare(amqpAdmin);
amqpAdmin.afterPropertiesSet();
return this.hystrixConnectionFactory;
}
return this.primaryConnectionFactory;

9
spring-cloud-netflix-turbine-amqp/pom.xml

@ -62,34 +62,25 @@ @@ -62,34 +62,25 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-amqp</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-java-dsl</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.netflix.turbine</groupId>
<artifactId>turbine-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>

6
spring-cloud-netflix-turbine-amqp/src/main/java/org/springframework/cloud/netflix/turbine/amqp/TurbineAmqpAutoConfiguration.java

@ -25,6 +25,7 @@ import org.springframework.amqp.core.BindingBuilder; @@ -25,6 +25,7 @@ import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -105,6 +106,11 @@ public class TurbineAmqpAutoConfiguration { @@ -105,6 +106,11 @@ public class TurbineAmqpAutoConfiguration {
private ConnectionFactory connectionFactory() {
if (this.turbineConnectionFactory != null) {
RabbitAdmin amqpAdmin = new RabbitAdmin(this.turbineConnectionFactory);
hystrixStreamExchange().setAdminsThatShouldDeclare(amqpAdmin);
localTurbineAmqpQueueBinding().setAdminsThatShouldDeclare(amqpAdmin);
hystrixStreamQueue().setAdminsThatShouldDeclare(amqpAdmin);
amqpAdmin.afterPropertiesSet();
return this.turbineConnectionFactory;
}
return this.primaryConnectionFactory;

Loading…
Cancel
Save