From 3f78ae9cd4ba98db92f6fc9a7cdf65d50a3ac12b Mon Sep 17 00:00:00 2001 From: a-dubaj Date: Thu, 31 Mar 2022 17:35:38 +0200 Subject: [PATCH 1/5] Added exchanges --- .../rabbitmqdemoapp/RabbitMqExchangeConfiguration.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java index a5409c5..227fb55 100644 --- a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java +++ b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java @@ -1,11 +1,11 @@ package com.andrzejdubaj.rabbitmqdemoapp; import org.springframework.amqp.core.Exchange; +import org.springframework.amqp.core.ExchangeBuilder; import org.springframework.amqp.core.TopicExchange; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; - @Configuration public class RabbitMqExchangeConfiguration { @@ -13,4 +13,12 @@ public class RabbitMqExchangeConfiguration { Exchange exampleExchange() { return new TopicExchange("ExampleExchange"); } + + @Bean + Exchange example2exchange() { + return ExchangeBuilder.directExchange("Example2exchange") + .autoDelete() + .internal() + .build(); + } } From 32d7595c5861a5bc22f4f05bfe5eb5a3c43ef442 Mon Sep 17 00:00:00 2001 From: a-dubaj Date: Thu, 31 Mar 2022 17:44:19 +0200 Subject: [PATCH 2/5] Added test exchanges --- .../RabbitMqExchangeConfiguration.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java index 227fb55..52b8255 100644 --- a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java +++ b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java @@ -5,6 +5,7 @@ import org.springframework.amqp.core.TopicExchange; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.retry.annotation.Backoff; @Configuration public class RabbitMqExchangeConfiguration { @@ -21,4 +22,31 @@ Exchange example2exchange() { .internal() .build(); } + + @Bean + Exchange newExchange() { + return ExchangeBuilder.topicExchange("TopicTestExchange") + .autoDelete() + .durable(true) + .internal() + .build(); + } + + @Bean + Exchange fanoutExchange(){ + return ExchangeBuilder.fanoutExchange("FanoutTestExchange") + .autoDelete() + .durable(false) + .internal() + .build(); + } + + @Bean + Exchange headersExchange(){ + return ExchangeBuilder.headersExchange("HeadersTestExchange") + .internal() + .durable(true) + .ignoreDeclarationExceptions() + .build(); + } } From a27c80c325ed0a6a5994c72a5945a09958d9cb7a Mon Sep 17 00:00:00 2001 From: a-dubaj Date: Thu, 31 Mar 2022 17:53:05 +0200 Subject: [PATCH 3/5] Update --- .../rabbitmqdemoapp/RabbitMQConfig.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMQConfig.java b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMQConfig.java index aefd635..6d212f2 100644 --- a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMQConfig.java +++ b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMQConfig.java @@ -1,6 +1,6 @@ package com.andrzejdubaj.rabbitmqdemoapp; -import org.springframework.amqp.core.Queue; +import org.springframework.amqp.core.*; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.listener.MessageListenerContainer; @@ -18,6 +18,23 @@ Queue myQueue() { return new Queue(MY_QUEUE, true); } + @Bean + Exchange myExchange() { + return ExchangeBuilder.topicExchange("TopicExchange") + .durable(true) + .build(); + } + + @Bean + Binding binding() { + //return new Binding(MY_QUEUE, Binding.DestinationType.QUEUE, "MyTopicExchange", "topic", null); + return BindingBuilder + .bind(myQueue()) + .to(myExchange()) + .with("topic") + .noargs(); + } + @Bean ConnectionFactory connectionFactory() { CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory("localhost"); From 2319edf3bd58e2a42cc5e345cdffed35b4bfad58 Mon Sep 17 00:00:00 2001 From: a-dubaj Date: Thu, 31 Mar 2022 18:09:05 +0200 Subject: [PATCH 4/5] Deleted unused import --- .../rabbitmqdemoapp/RabbitMqExchangeConfiguration.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java index 52b8255..88f3762 100644 --- a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java +++ b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMqExchangeConfiguration.java @@ -5,7 +5,6 @@ import org.springframework.amqp.core.TopicExchange; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.retry.annotation.Backoff; @Configuration public class RabbitMqExchangeConfiguration { From 59cf8c34e665112b0c1a0d8d4d2b846c820954ad Mon Sep 17 00:00:00 2001 From: a-dubaj Date: Thu, 31 Mar 2022 19:18:36 +0200 Subject: [PATCH 5/5] Update --- .../andrzejdubaj/rabbitmqdemoapp/RabbitMQQueueConfiguration.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMQQueueConfiguration.java b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMQQueueConfiguration.java index fd4a2cd..9dadfea 100644 --- a/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMQQueueConfiguration.java +++ b/src/main/java/com/andrzejdubaj/rabbitmqdemoapp/RabbitMQQueueConfiguration.java @@ -12,7 +12,6 @@ public class RabbitMQQueueConfiguration { Queue exampleQueue() { return new Queue("ExampleQueue", false); } - @Bean Queue example2andQueue() { return QueueBuilder.durable("Example2ndQueue")