Commit cc2159f7 by Dave Syer

Use separate RabbitAdmin to declare queues and exchanges

Fixes gh-259
parent 9fe69cc8
......@@ -29,22 +29,16 @@
<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>
</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>
......
......@@ -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 {
// 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 {
private ConnectionFactory connectionFactory() {
if (this.hystrixConnectionFactory != null) {
RabbitAdmin amqpAdmin = new RabbitAdmin(this.hystrixConnectionFactory);
hystrixStreamExchange().setAdminsThatShouldDeclare(amqpAdmin);
amqpAdmin.afterPropertiesSet();
return this.hystrixConnectionFactory;
}
return this.primaryConnectionFactory;
......
......@@ -63,33 +63,24 @@
<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>
......
......@@ -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 {
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment