From a27c80c325ed0a6a5994c72a5945a09958d9cb7a Mon Sep 17 00:00:00 2001 From: a-dubaj Date: Thu, 31 Mar 2022 17:53:05 +0200 Subject: [PATCH] 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");