diff --git a/luoo_comment/src/main/java/com/luoo/comment/listener/UserInfoCommentCacheListener.java b/luoo_comment/src/main/java/com/luoo/comment/listener/UserInfoCommentCacheListener.java index ad22dd1..22def81 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/listener/UserInfoCommentCacheListener.java +++ b/luoo_comment/src/main/java/com/luoo/comment/listener/UserInfoCommentCacheListener.java @@ -4,6 +4,7 @@ package com.luoo.comment.listener; import com.luoo.comment.dao.CommentDao; import com.luoo.comment.pojo.Comment; import constants.Constants; +import lombok.extern.slf4j.Slf4j; import net.oschina.j2cache.CacheChannel; import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitListener; @@ -14,6 +15,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; +@Slf4j @Component @RabbitListener(queues = "userInfoCommentCache") public class UserInfoCommentCacheListener { @@ -26,6 +28,8 @@ public class UserInfoCommentCacheListener { @RabbitHandler public void excuteClearCache(String userId) { + log.info("userInfoCommentCacheListener clear cache userId:{}",userId); + List commentList = commentDao.findAllByUserId(userId); Set journalIdSet = commentList.parallelStream().map(comment -> comment.getRootJournalId()).collect(Collectors.toSet()); Set parentIdSet = commentList.parallelStream().map(comment -> comment.getParentId()).collect(Collectors.toSet()); diff --git a/luoo_music/src/main/java/com/luoo/music/config/RabbitMQConfig.java b/luoo_music/src/main/java/com/luoo/music/config/RabbitMQConfig.java index 61d904d..3da8250 100644 --- a/luoo_music/src/main/java/com/luoo/music/config/RabbitMQConfig.java +++ b/luoo_music/src/main/java/com/luoo/music/config/RabbitMQConfig.java @@ -1,35 +1,35 @@ -//package com.luoo.music.config; -// -//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.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -// -///** -// * @Author: yawei.huang -// * @Package: com.macro.mall.config -// * @Project: macrozhengmall -// * @Date: 2024/5/8 14:13 -// * @Filename: RabbitMQConfig -// * @Describe: -// */ -//@Configuration -//public class RabbitMQConfig { -// -// @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.setConnectionFactory(connectionFactory); -// factory.setMessageConverter(new Jackson2JsonMessageConverter()); -// return factory; -// } -//} +package com.luoo.music.config; + +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.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @Author: yawei.huang + * @Package: com.macro.mall.config + * @Project: macrozhengmall + * @Date: 2024/5/8 14:13 + * @Filename: RabbitMQConfig + * @Describe: + */ +@Configuration +public class RabbitMQConfig { + + @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.setConnectionFactory(connectionFactory); + factory.setMessageConverter(new Jackson2JsonMessageConverter()); + return factory; + } +} 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 new file mode 100644 index 0000000..dc0154b --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/config/RabbitMQConfig.java @@ -0,0 +1,27 @@ +package com.luoo.user.config; + +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.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RabbitMQConfig { + + @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.setConnectionFactory(connectionFactory); + factory.setMessageConverter(new Jackson2JsonMessageConverter()); + return factory; + } +}