From e6d0bba0ed44272189b264b790c438a4caa92c0f Mon Sep 17 00:00:00 2001 From: Luoye_W Date: Mon, 26 Jul 2021 10:44:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4rabbitmq=20=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0webflux=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 22 ++--- .../e5/config/rabbitMQ/RabbitMQConfig.java | 83 ------------------- .../e5/controller/admin/AdminController.java | 6 -- .../io/qyi/e5/service/task/impl/TaskImpl.java | 5 -- 4 files changed, 11 insertions(+), 105 deletions(-) delete mode 100644 src/main/java/io/qyi/e5/config/rabbitMQ/RabbitMQConfig.java diff --git a/pom.xml b/pom.xml index db31589..1bc2ced 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.1.RELEASE + 2.5.2 io.qyi @@ -135,21 +135,14 @@ commons-lang3 3.9 - org.aspectj aspectjrt - org.aspectj aspectjweaver - org.jetbrains @@ -157,14 +150,21 @@ RELEASE compile - + + org.springframework.boot + spring-boot-starter-webflux + + + + - + <!–${version}–> + --> + diff --git a/src/main/java/io/qyi/e5/config/rabbitMQ/RabbitMQConfig.java b/src/main/java/io/qyi/e5/config/rabbitMQ/RabbitMQConfig.java deleted file mode 100644 index 17a8577..0000000 --- a/src/main/java/io/qyi/e5/config/rabbitMQ/RabbitMQConfig.java +++ /dev/null @@ -1,83 +0,0 @@ -package io.qyi.e5.config.rabbitMQ; - -import org.springframework.amqp.core.*; -import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; -import org.springframework.amqp.rabbit.connection.ConnectionFactory; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.HashMap; -import java.util.Map; - -/** - * @program: msgpush - * @description: - * @author: 落叶随风 - * @create: 2020-01-12 22:00 - **/ -@Configuration -public class RabbitMQConfig { - @Value("") - private String DirectQueueName; - - /** - * 处理死信队列的消费队列 - */ - @Bean - public Queue fanoutQueue1() { - return new Queue("delay_queue1", true, false, false); - } - - /** - * 配置消息交换机 - * 针对消费者配置 - * FanoutExchange: 将消息分发到所有的绑定队列,无routingkey的概念 - * HeadersExchange :通过添加属性key-value匹配 - * DirectExchange:按照routingkey分发到指定队列 - * TopicExchange:多关键字匹配 - * - * @return - */ - @Bean - public CustomExchange customExchangeDelay() { - Map arg = new HashMap<>(); - arg.put("x-delayed-type", "direct"); - return new CustomExchange("delay", "x-delayed-message", true, false, arg); - } - - /*@Bean - public FanoutExchange fanoutExchangeTencentMsg() { - return new FanoutExchange(EXCHANGE); - }*/ - - //绑定 将队列和交换机绑定, - @Bean - public Binding bindingFanoutQueue1() { - return BindingBuilder.bind(fanoutQueue1()).to(customExchangeDelay()).with("routing_delay").noargs(); - } - - - // 无限循环问题 - @Bean - public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) { - RabbitTemplate template = new RabbitTemplate(connectionFactory); - template.setMessageConverter(new Jackson2JsonMessageConverter()); - return template; - } - - @Bean - public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) { - SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); - factory.setAcknowledgeMode(AcknowledgeMode.MANUAL); - factory.setConcurrentConsumers(1); - factory.setMaxConcurrentConsumers(50); - factory.setPrefetchCount(20); - factory.setConnectionFactory(connectionFactory); - factory.setMessageConverter(new Jackson2JsonMessageConverter()); - return factory; - } - -} diff --git a/src/main/java/io/qyi/e5/controller/admin/AdminController.java b/src/main/java/io/qyi/e5/controller/admin/AdminController.java index 716fe83..5b1149f 100644 --- a/src/main/java/io/qyi/e5/controller/admin/AdminController.java +++ b/src/main/java/io/qyi/e5/controller/admin/AdminController.java @@ -1,15 +1,11 @@ package io.qyi.e5.controller.admin; -import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken; import io.qyi.e5.outlook.service.IOutlookService; import io.qyi.e5.service.task.ITask; import io.qyi.e5.util.EncryptUtil; -import io.qyi.e5.util.StringUtil; import io.qyi.e5.util.redis.RedisUtil; -import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.util.ResourceUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -30,8 +26,6 @@ import java.util.*; @RestController @RequestMapping("/admin") public class AdminController { - @Autowired - RabbitTemplate rabbitTemplate; @Autowired IOutlookService outlookService; diff --git a/src/main/java/io/qyi/e5/service/task/impl/TaskImpl.java b/src/main/java/io/qyi/e5/service/task/impl/TaskImpl.java index 2db6744..51cd83e 100644 --- a/src/main/java/io/qyi/e5/service/task/impl/TaskImpl.java +++ b/src/main/java/io/qyi/e5/service/task/impl/TaskImpl.java @@ -9,9 +9,6 @@ import io.qyi.e5.service.task.ITask; import io.qyi.e5.util.redis.RedisUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.amqp.core.MessageProperties; -import org.springframework.amqp.rabbit.connection.CorrelationData; -import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; @@ -34,8 +31,6 @@ public class TaskImpl implements ITask { @Autowired IOutlookService outlookService; - @Autowired - RabbitTemplate rabbitTemplate; @Autowired RedisUtil redisUtil;