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 {