From b9098dadc5da813cc063e3ec8311e6e30967fd2a Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Tue, 26 Nov 2024 13:25:37 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E7=A7=AF=E5=88=86=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=8D=95=E7=BA=BF=E7=A8=8B=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/luoo/user/config/RabbitMQConfig.java | 9 +++++++++ .../java/com/luoo/user/listener/PointLogListener.java | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/luoo_user/src/main/java/com/luoo/user/config/RabbitMQConfig.java b/luoo_user/src/main/java/com/luoo/user/config/RabbitMQConfig.java index dc0154b..978db06 100644 --- a/luoo_user/src/main/java/com/luoo/user/config/RabbitMQConfig.java +++ b/luoo_user/src/main/java/com/luoo/user/config/RabbitMQConfig.java @@ -24,4 +24,13 @@ public class RabbitMQConfig { factory.setMessageConverter(new Jackson2JsonMessageConverter()); return factory; } + + @Bean + public SimpleRabbitListenerContainerFactory pointLogFactory(ConnectionFactory connectionFactory) { + SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); + factory.setConnectionFactory(connectionFactory); + factory.setMessageConverter(new Jackson2JsonMessageConverter()); + factory.setPrefetchCount(1); + return factory; + } } diff --git a/luoo_user/src/main/java/com/luoo/user/listener/PointLogListener.java b/luoo_user/src/main/java/com/luoo/user/listener/PointLogListener.java index 42c1468..0d0cf77 100644 --- a/luoo_user/src/main/java/com/luoo/user/listener/PointLogListener.java +++ b/luoo_user/src/main/java/com/luoo/user/listener/PointLogListener.java @@ -6,12 +6,10 @@ import com.luoo.user.service.UserPointLogService; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.IOException; -import java.util.Map; /** * @program: luoo_parent @@ -20,7 +18,7 @@ import java.util.Map; * @create: 2024-07-24 13:05 **/ @Component -@RabbitListener(queues = "pointLog") +@RabbitListener(queues = "pointLog", containerFactory = "pointLogFactory") @Slf4j public class PointLogListener {