Browse Source

Merge remote-tracking branch 'remotes/origin/dev_group_point' into dev_temp

master
jianjun 4 years ago
parent
commit
e87b4d33e8
  1. 5
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/mq/GroupAchieventConsumerListener.java
  2. 14
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/mq/type1/GroupAchievementCustomListener.java

5
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/mq/GroupAchieventConsumerListener.java

@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
//@Component
//@RocketMQMessageListener(topic = "group_achievement", consumerGroup = ConsomerGroupConstants.GROUP_ACHIEVEMENT_COMPONENTS_GROUP)
//@Component
public class GroupAchieventConsumerListener implements RocketMQListener<GroupAchievementMQMsg> {
@Autowired
private StatsAchievementService statsAchievementService;
@ -28,10 +27,10 @@ public class GroupAchieventConsumerListener implements RocketMQListener<GroupAch
log.info("receive msg:{}", JSON.toJSONString(msg));
if (StringUtils.isBlank(msg.getAchievementType()) || StringUtils.isBlank(msg.getCustomerId())
|| StringUtils.isBlank(msg.getGroupId())) {
log.error("consumer fail,msg:{}", msg);
log.error("consumer groupAchievement fail,msg:{}", msg);
return;
}
Boolean aBoolean = statsAchievementService.calculateAcm(msg.getCustomerId(), msg.getGroupId(), msg.getAchievementType());
log.info("consumer msg success,{}", aBoolean);
log.info("consumer groupAchievement msg success,{}", aBoolean);
}
}

14
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/mq/type1/GroupAchievementCustomListener.java

@ -48,24 +48,22 @@ public class GroupAchievementCustomListener implements MessageListenerConcurrent
RLock lock = null;
try {
distributedLock = SpringContextUtils.getBean(DistributedLock.class);
lock = distributedLock.getLock(String.format("lock:init_customer_org:%s", msgObj.getCustomerId()),
30l, 30l, TimeUnit.SECONDS);
lock = distributedLock.getLock(String.format("lock:group_achievement:%s", msgObj.getCustomerId())
,30L, 30L, TimeUnit.SECONDS);
if (StringUtils.isBlank(msgObj.getAchievementType()) || StringUtils.isBlank(msgObj.getCustomerId())
|| StringUtils.isBlank(msgObj.getGroupId())){
logger.error("consumer fail,msg:{}",msgObj);
logger.error("consumer groupAchievement fail,msg:{}",msgObj);
return;
}
//消息被消费太快 业务数据还没有完成 歇一会先
try {
Thread.sleep(200L);
Thread.sleep(60L);
} catch (InterruptedException e) {
logger.error("consumeMessage sleep",e);
logger.error("consumeMessage sleep exception",e);
}
Boolean aBoolean = SpringContextUtils.getBean(StatsAchievementService.class).calculateAcm(msgObj.getCustomerId(), msgObj.getGroupId(), msgObj.getAchievementType());
logger.info("consumer msg success,{}",aBoolean);
logger.info("consumer groupAchievement msg success,{}",aBoolean);
} catch (RenException e) {
// 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
logger.error("【RocketMQ】消费小组成就消息失败:",e);

Loading…
Cancel
Save