feat(count): 实现关注与粉丝数统计功能
- 新增关注数与粉丝数 MQ 消费者 - 在用户关系服务中新增关注/取关时发送 MQ 消息逻辑 - 新增关注/取关类型枚举类 - 新增用于统计的 MQ 常量定义 - 调整应用主类包路径以符合项目结构(致命,查半天) - 移除配置文件中不再使用的 MQ 消费者限流配置项
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.hanserwei.hannote.count.biz.domain;
|
||||
package com.hanserwei.hannote.count.biz;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.hanserwei.hannote.count.biz.constant;
|
||||
|
||||
public interface MQConstants {
|
||||
|
||||
/**
|
||||
* Topic: 关注数计数
|
||||
*/
|
||||
String TOPIC_COUNT_FOLLOWING = "CountFollowingTopic";
|
||||
|
||||
/**
|
||||
* Topic: 粉丝数计数
|
||||
*/
|
||||
String TOPIC_COUNT_FANS = "CountFansTopic";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hanserwei.hannote.count.biz.consumer;
|
||||
|
||||
import com.hanserwei.hannote.count.biz.constant.MQConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RocketMQMessageListener(
|
||||
consumerGroup = "han_note_group_" + MQConstants.TOPIC_COUNT_FANS,
|
||||
topic = MQConstants.TOPIC_COUNT_FANS
|
||||
)
|
||||
@Slf4j
|
||||
public class CountFansConsumer implements RocketMQListener<String> {
|
||||
@Override
|
||||
public void onMessage(String body) {
|
||||
log.info("## 消费了 MQ [计数:粉丝数]: {}", body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hanserwei.hannote.count.biz.consumer;
|
||||
|
||||
import com.hanserwei.hannote.count.biz.constant.MQConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RocketMQMessageListener(
|
||||
consumerGroup = "han_note_group_" + MQConstants.TOPIC_COUNT_FOLLOWING,
|
||||
topic = MQConstants.TOPIC_COUNT_FOLLOWING
|
||||
)
|
||||
@Slf4j
|
||||
public class CountFollowingConsumer implements RocketMQListener<String> {
|
||||
@Override
|
||||
public void onMessage(String body) {
|
||||
log.info("## 消费了 MQ [计数:关注数]: {}", body);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,4 @@ mybatis-plus:
|
||||
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
global-config:
|
||||
banner: false
|
||||
mapper-locations: classpath*:/mapperxml/*.xml
|
||||
mq-consumer: # MQ 消费者
|
||||
follow-unfollow: # 关注、取关
|
||||
rate-limit: 5000 # 每秒限流阈值
|
||||
mapper-locations: classpath*:/mapperxml/*.xml
|
||||
Reference in New Issue
Block a user