删除旧的消费者
This commit is contained in:
@@ -2,8 +2,7 @@ package com.accompany.business.service.mq;
|
||||
|
||||
import com.accompany.business.message.*;
|
||||
import com.accompany.business.message.linearlypool.LinearlyPoolPrizeMessage;
|
||||
import com.accompany.business.service.mq.listener.*;
|
||||
import com.accompany.core.base.SpringContextHolder;
|
||||
import com.accompany.mq.constant.MqConstant;
|
||||
import com.accompany.mq.producer.MQMessageProducer;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -26,9 +25,9 @@ public class RocketMQService {
|
||||
* @param giftMessage
|
||||
*/
|
||||
public void sendGiftMessage(GiftMessage giftMessage) {
|
||||
mqMessageProducer.send(RocketMQConstant.GIFT_TOPIC, giftMessage, sendResult -> log.info("sendGiftMessage success message: {}", JSON.toJSONString(giftMessage)), throwable -> {
|
||||
mqMessageProducer.send(MqConstant.GIFT_TOPIC, giftMessage, sendResult -> log.info("sendGiftMessage success message: {}", JSON.toJSONString(giftMessage)), throwable -> {
|
||||
log.error("sendGiftMessage fail message: {}", JSON.toJSONString(giftMessage), throwable);
|
||||
SpringContextHolder.getBean(GiftMessageMQListener.class).onMessage(giftMessage);
|
||||
//SpringContextHolder.getBean(GiftMessageMQListener.class).onMessage(giftMessage);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,16 +35,16 @@ public class RocketMQService {
|
||||
* 发送开箱子中奖消息
|
||||
*/
|
||||
public void sendOpenBoxMessage(BoxPrizeMessage message) {
|
||||
mqMessageProducer.sendOrderly(RocketMQConstant.OPEN_BOX_TOPIC, message, message.getUid().toString(), sendResult -> log.info("sendOpenBoxMessage success message: {} queue {}", JSON.toJSONString(message), sendResult.getMessageQueue().getQueueId()), throwable -> {
|
||||
mqMessageProducer.sendOrderly(MqConstant.OPEN_BOX_TOPIC, message, message.getUid().toString(), sendResult -> log.info("sendOpenBoxMessage success message: {} queue {}", JSON.toJSONString(message), sendResult.getMessageQueue().getQueueId()), throwable -> {
|
||||
log.error("sendOpenBoxMessage fail message: {}", JSON.toJSONString(message), throwable);
|
||||
SpringContextHolder.getBean(OpenBoxPrizeMessageMQListener.class).onMessage(message);
|
||||
//SpringContextHolder.getBean(OpenBoxPrizeMessageMQListener.class).onMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
public void sendLinearlyPoolDrawMessage(LinearlyPoolPrizeMessage message) {
|
||||
mqMessageProducer.sendOrderly(RocketMQConstant.LINEARLY_POOL_TOPIC, message, message.getUid().toString(), sendResult -> log.info("sendLinearlyPoolDrawMessage success message: {} queue {}", JSON.toJSONString(message), sendResult.getMessageQueue().getQueueId()), throwable -> {
|
||||
mqMessageProducer.sendOrderly(MqConstant.LINEARLY_POOL_TOPIC, message, message.getUid().toString(), sendResult -> log.info("sendLinearlyPoolDrawMessage success message: {} queue {}", JSON.toJSONString(message), sendResult.getMessageQueue().getQueueId()), throwable -> {
|
||||
log.error("sendLinearlyPoolDrawMessage fail message: {}", JSON.toJSONString(message), throwable);
|
||||
SpringContextHolder.getBean(LinearlyPoolPrizeMessageMQListener.class).onMessage(message);
|
||||
//SpringContextHolder.getBean(LinearlyPoolPrizeMessageMQListener.class).onMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -55,9 +54,9 @@ public class RocketMQService {
|
||||
* @param message
|
||||
*/
|
||||
public void sendCleanMusicDelayMessage(CleanMusicDelayMessage message) {
|
||||
mqMessageProducer.send(RocketMQConstant.CLEAN_MUSIC_TOPIC, message, sendResult -> log.info("sendCleanMusicDelayMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
mqMessageProducer.send(MqConstant.CLEAN_MUSIC_TOPIC, message, sendResult -> log.info("sendCleanMusicDelayMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
log.error("sendCleanMusicDelayMessage fail message: {}", JSON.toJSONString(message), throwable);
|
||||
SpringContextHolder.getBean(CleanMusicDelayMessageMQListener.class).onMessage(message);
|
||||
//SpringContextHolder.getBean(CleanMusicDelayMessageMQListener.class).onMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -67,9 +66,9 @@ public class RocketMQService {
|
||||
* @param packMessage
|
||||
*/
|
||||
public void sendActivityPackMessage(ActivityPackMessage packMessage) {
|
||||
mqMessageProducer.send(RocketMQConstant.ACTIVITY_PACK_TOPIC, packMessage, sendResult -> log.info("sendActivityPackMessage success message: {}", packMessage), throwable -> {
|
||||
mqMessageProducer.send(MqConstant.ACTIVITY_PACK_TOPIC, packMessage, sendResult -> log.info("sendActivityPackMessage success message: {}", packMessage), throwable -> {
|
||||
log.error("sendActivityPackMessage fail message: {}", packMessage, throwable);
|
||||
SpringContextHolder.getBean(ActivityPackMessageMQListener.class).onMessage(packMessage);
|
||||
//SpringContextHolder.getBean(ActivityPackMessageMQListener.class).onMessage(packMessage);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,9 +78,9 @@ public class RocketMQService {
|
||||
* @param message
|
||||
*/
|
||||
public void sendSignDrawGoldMessage(SignDrawGoldMessage message) {
|
||||
mqMessageProducer.send(RocketMQConstant.SIGN_DRAW_GOLD_TOPIC, message, sendResult -> log.info("sendSignDrawGoldMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
mqMessageProducer.send(MqConstant.SIGN_DRAW_GOLD_TOPIC, message, sendResult -> log.info("sendSignDrawGoldMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
log.error("sendSignDrawGoldMessage fail message: {}", JSON.toJSONString(message), throwable);
|
||||
SpringContextHolder.getBean(SignDrawGoldMessageMQListener.class).onMessage(message);
|
||||
//SpringContextHolder.getBean(SignDrawGoldMessageMQListener.class).onMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,9 +90,9 @@ public class RocketMQService {
|
||||
* @param message
|
||||
*/
|
||||
public void sendSignMessage(SignMessage message) {
|
||||
mqMessageProducer.send(RocketMQConstant.SIGN_TOPIC, message, sendResult -> log.info("sendSignMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
mqMessageProducer.send(MqConstant.SIGN_TOPIC, message, sendResult -> log.info("sendSignMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
log.error("sendSignMessage fail message: {}", JSON.toJSONString(message), throwable);
|
||||
SpringContextHolder.getBean(SignMessageMQListener.class).onMessage(message);
|
||||
//SpringContextHolder.getBean(SignMessageMQListener.class).onMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -103,9 +102,9 @@ public class RocketMQService {
|
||||
* @param message
|
||||
*/
|
||||
public void sendRadishGiftMessage(RadishGiftMessage message) {
|
||||
mqMessageProducer.send(RocketMQConstant.RADISH_GIFT_TOPIC, message, sendResult -> log.info("sendRadishGiftMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
mqMessageProducer.send(MqConstant.RADISH_GIFT_TOPIC, message, sendResult -> log.info("sendRadishGiftMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
log.error("sendRadishGiftMessage fail message: {}", JSON.toJSONString(message), throwable);
|
||||
SpringContextHolder.getBean(RadishGiftMessageMQListener.class).onMessage(message);
|
||||
//SpringContextHolder.getBean(RadishGiftMessageMQListener.class).onMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -115,9 +114,9 @@ public class RocketMQService {
|
||||
* @param message
|
||||
*/
|
||||
public void sendPayFinishMessage(PayFinishMessage message) {
|
||||
mqMessageProducer.send(RocketMQConstant.PAY_FINISH_TOPIC, message, sendResult -> log.info("send payFinish success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
mqMessageProducer.send(MqConstant.PAY_FINISH_TOPIC, message, sendResult -> log.info("send payFinish success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
log.error("send payFinish fail message: {}", JSON.toJSONString(message), throwable);
|
||||
SpringContextHolder.getBean(PayFinishMessageMQListener.class).onMessage(message);
|
||||
//SpringContextHolder.getBean(PayFinishMessageMQListener.class).onMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -127,9 +126,9 @@ public class RocketMQService {
|
||||
* @param message
|
||||
*/
|
||||
public void sendVoiceLikeMessage(VoiceLikeMessage message) {
|
||||
mqMessageProducer.send(RocketMQConstant.VOICE_LIKE_TOPIC, message, sendResult -> log.info("sendVoiceLikeMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
mqMessageProducer.send(MqConstant.VOICE_LIKE_TOPIC, message, sendResult -> log.info("sendVoiceLikeMessage success message: {}", JSON.toJSONString(message)), throwable -> {
|
||||
log.error("sendVoiceLikeMessage fail message: {}", JSON.toJSONString(message), throwable);
|
||||
SpringContextHolder.getBean(VoiceLikeMessageMQListener.class).onMessage(message);
|
||||
//SpringContextHolder.getBean(VoiceLikeMessageMQListener.class).onMessage(message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,9 +138,9 @@ public class RocketMQService {
|
||||
* @param msg
|
||||
*/
|
||||
public void sendYidunIMTextAntiMsg(YidunIMAntiMessage msg) {
|
||||
mqMessageProducer.send(RocketMQConstant.YIDUN_TEXT_ANTI_TOPIC, msg, sendResult -> log.info("sendYidunIMTextAntiMsg success message: {}", JSON.toJSONString(msg)), throwable -> {
|
||||
mqMessageProducer.send(MqConstant.YI_DUN_TEXT_ANTI_TOPIC, msg, sendResult -> log.info("sendYidunIMTextAntiMsg success message: {}", JSON.toJSONString(msg)), throwable -> {
|
||||
log.error("sendYidunIMTextAntiMsg fail message: {}", JSON.toJSONString(msg), throwable);
|
||||
SpringContextHolder.getBean(YidunIMTextAntiMessageMQListener.class).onMessage(msg);
|
||||
//SpringContextHolder.getBean(YidunIMTextAntiMessageMQListener.class).onMessage(msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -1,42 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.ActivityPackMessage;
|
||||
import com.accompany.business.service.activity.ActivityPackMessageService;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 礼包消息监听器
|
||||
* @author xiaoyuyou
|
||||
* @date 2018/9/5 11:03
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.ACTIVITY_PACK_TOPIC, consumerGroup = RocketMQConstant.ACTIVITY_PACK_CONSUME_GROUP)
|
||||
public class ActivityPackMessageMQListener implements RocketMQListener<ActivityPackMessage> {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private ActivityPackMessageService activityPackMessageService;
|
||||
|
||||
public void onMessage(ActivityPackMessage packMessage) {
|
||||
log.info("handle activity pack message {}", JSON.toJSONString(packMessage));
|
||||
// 判断该消息是否已经消费过
|
||||
String messStatus = jedisService.hget(RedisKey.mq_pack_status.getKey(), packMessage.getMessId());
|
||||
if (BlankUtil.isBlank(messStatus)) {
|
||||
return;
|
||||
}
|
||||
activityPackMessageService.handleActivityPackMessage(packMessage);
|
||||
}
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.CleanMusicDelayMessage;
|
||||
import com.accompany.business.service.ktv.UserChooseMusicService;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.business.service.user.UserInRoomService;
|
||||
import com.accompany.business.vo.RoomVo;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 清歌消息监听器
|
||||
* @author xiaoyuyou
|
||||
* @date 2018/9/5 11:03
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.CLEAN_MUSIC_TOPIC, consumerGroup = RocketMQConstant.CLEAN_MUSIC_CONSUME_GROUP)
|
||||
public class CleanMusicDelayMessageMQListener implements RocketMQListener<CleanMusicDelayMessage> {
|
||||
|
||||
@Autowired
|
||||
private UserChooseMusicService userChooseMusicService;
|
||||
@Autowired
|
||||
private UserInRoomService userInRoomService;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
|
||||
@SneakyThrows
|
||||
public void onMessage(CleanMusicDelayMessage cleanMusicMsg) {
|
||||
log.info("clean music delay message {}", JSON.toJSONString(cleanMusicMsg));
|
||||
Long roomUid = cleanMusicMsg.getRoomUid();
|
||||
Long uid = cleanMusicMsg.getUid();
|
||||
String messId = jedisService.hget(RedisKey.room_clean_music_messId.getKey(), roomUid + "_" + uid);
|
||||
log.info("clean music listener exec, roomUid:{}, uid:{}, period:{}, redis messId:{}, current messId:{}",
|
||||
roomUid, uid, System.currentTimeMillis() - cleanMusicMsg.getMessTime(), messId, cleanMusicMsg.getMessId());
|
||||
if (StringUtils.isEmpty(messId) || !StringUtils.equals(messId, cleanMusicMsg.getMessId())){
|
||||
return;
|
||||
}
|
||||
RoomVo roomVo = userInRoomService.getUserInRoomInfoCache(uid);
|
||||
if (roomVo == null || roomVo.getUid().longValue() != roomUid.longValue()){
|
||||
userChooseMusicService.deleteUserAllChooseMusic(roomUid, uid);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.GiftMessage;
|
||||
import com.accompany.business.service.gift.GiftMessageService;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.GIFT_TOPIC, consumerGroup = RocketMQConstant.GIFT_CONSUME_GROUP)
|
||||
public class GiftMessageMQListener implements RocketMQListener<GiftMessage> {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private GiftMessageService giftMessageService;
|
||||
|
||||
public void onMessage(GiftMessage giftMessage) {
|
||||
log.info("onMessage giftMessage: {}", giftMessage.toString());
|
||||
// 判断该消息是否已经消费过
|
||||
String messStatus = jedisService.hget(RedisKey.mq_gift_status.getKey(), giftMessage.getMessId());
|
||||
if (BlankUtil.isBlank(messStatus)) {
|
||||
return;
|
||||
}
|
||||
giftMessageService.handleGiftMessage(giftMessage);
|
||||
}
|
||||
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.linearlypool.LinearlyPoolPrizeMessage;
|
||||
import com.accompany.business.service.linearlypool.LinearlyPoolPrizeMessageService;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.ConsumeMode;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 线性奖池中奖消息
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.LINEARLY_POOL_TOPIC, consumerGroup = RocketMQConstant.LINEARLY_POOL_CONSUME_GROUP, consumeMode = ConsumeMode.ORDERLY)
|
||||
public class LinearlyPoolPrizeMessageMQListener implements RocketMQListener<LinearlyPoolPrizeMessage> {
|
||||
|
||||
@Autowired
|
||||
private LinearlyPoolPrizeMessageService prizeMessageService;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
|
||||
public void onMessage(LinearlyPoolPrizeMessage message) {
|
||||
Thread thread = Thread.currentThread();
|
||||
log.info("{} thread handle linearly-pool-draw-queue message {}", thread.getName(), JSON.toJSONString(message));
|
||||
|
||||
prizeMessageService.onMessage(message);
|
||||
|
||||
// 删除消息标识
|
||||
jedisService.hdel(RedisKey.mq_linearly_pool_prize_status.getKey(), message.getMessId());
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.BoxPrizeMessage;
|
||||
import com.accompany.business.service.box.BoxPrizeMessageService;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.ConsumeMode;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by PaperCut on 2018/7/16.
|
||||
* 开箱子中奖消息
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.OPEN_BOX_TOPIC, consumerGroup = RocketMQConstant.OPEN_BOX_CONSUME_GROUP, consumeMode = ConsumeMode.ORDERLY)
|
||||
public class OpenBoxPrizeMessageMQListener implements RocketMQListener<BoxPrizeMessage> {
|
||||
|
||||
@Autowired
|
||||
private BoxPrizeMessageService boxPrizeMessageService;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
|
||||
public void onMessage(BoxPrizeMessage message) {
|
||||
Thread thread = Thread.currentThread();
|
||||
log.info("{} thread handle openbox-queue message {}", thread.getName(), JSON.toJSONString(message));
|
||||
boxPrizeMessageService.onMessage(message);
|
||||
|
||||
// 删除消息标识
|
||||
jedisService.hdel(RedisKey.mq_prize_status.getKey(), message.getMessId());
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.PayFinishMessage;
|
||||
import com.accompany.business.service.activity.ChargeActivityPackRecordService;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.payment.model.ChargeRecord;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 处理支付完成后的一些操作
|
||||
* 如:
|
||||
* 1. 充值送礼包:充值完成后,判断用户的充值金额、次数等,并发放相应的礼包
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.PAY_FINISH_TOPIC, consumerGroup = RocketMQConstant.PAY_FINISH_CONSUME_GROUP)
|
||||
public class PayFinishMessageMQListener implements RocketMQListener<PayFinishMessage> {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private ChargeActivityPackRecordService chargeActivityPackRecordService;
|
||||
|
||||
private final Gson gson = new Gson();
|
||||
|
||||
public void onMessage(PayFinishMessage payFinishMessage) {
|
||||
log.info("onMessage payFinishMessage: {}", JSON.toJSONString(payFinishMessage));
|
||||
// 判断该消息是否已经消费过
|
||||
String messStatus = jedisService.hget(RedisKey.mq_pay_finish_status.getKey(), payFinishMessage.getMessId());
|
||||
if (BlankUtil.isBlank(messStatus)) {
|
||||
log.info("消息已处理,消息id:{}", payFinishMessage.getMessId());
|
||||
return;
|
||||
}
|
||||
|
||||
//处理具体逻辑
|
||||
ChargeRecord chargeRecord = gson.fromJson(messStatus, ChargeRecord.class);
|
||||
//处理首充礼包
|
||||
chargeActivityPackRecordService.handleFirstChargeActivityPack(chargeRecord);
|
||||
|
||||
//消费完成,删除该消息
|
||||
jedisService.hdel(RedisKey.mq_pay_finish_status.getKey(), payFinishMessage.getMessId());
|
||||
}
|
||||
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.RadishGiftMessage;
|
||||
import com.accompany.business.service.gift.RadishGiftMessageService;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.RADISH_GIFT_TOPIC, consumerGroup = RocketMQConstant.RADISH_GIFT_CONSUME_GROUP)
|
||||
public class RadishGiftMessageMQListener implements RocketMQListener<RadishGiftMessage> {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private RadishGiftMessageService radishGiftMessageService;
|
||||
|
||||
public void onMessage(RadishGiftMessage radishGiftMessage) {
|
||||
log.info("onMessage radishGiftMessage: {}", radishGiftMessage.toString());
|
||||
// 判断该消息是否已经消费过
|
||||
String messStatus = jedisService.hget(RedisKey.mq_radish_gift_status.getKey(), radishGiftMessage.getMessId());
|
||||
if (BlankUtil.isBlank(messStatus)) {
|
||||
return;
|
||||
}
|
||||
radishGiftMessageService.handleRadishGiftMessage(radishGiftMessage);
|
||||
}
|
||||
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.SignDrawGoldMessage;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.business.service.signweb.SignDrawGoldService;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 瓜分金币
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.SIGN_DRAW_GOLD_TOPIC, consumerGroup = RocketMQConstant.SIGN_DRAW_GOLD_CONSUME_GROUP)
|
||||
public class SignDrawGoldMessageMQListener implements RocketMQListener<SignDrawGoldMessage> {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private SignDrawGoldService signDrawGoldService;
|
||||
|
||||
@SneakyThrows
|
||||
public void onMessage(SignDrawGoldMessage signDrawGoldMessage) {
|
||||
log.info("onMessage signDrawGoldMessage: {}", JSON.toJSONString(signDrawGoldMessage));
|
||||
|
||||
// 判断该消息是否已经消费过
|
||||
String messStatus = jedisService.hget(RedisKey.mq_sign_draw_gold_status.getKey(), signDrawGoldMessage.getMessId());
|
||||
if (BlankUtil.isBlank(messStatus)) {
|
||||
return;
|
||||
}
|
||||
signDrawGoldService.handleDrawGoldMessage(signDrawGoldMessage);
|
||||
}
|
||||
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.SignMessage;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.business.service.signweb.SignService;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 每日签到奖励发放
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.SIGN_TOPIC, consumerGroup = RocketMQConstant.SIGN_CONSUME_GROUP)
|
||||
public class SignMessageMQListener implements RocketMQListener<SignMessage> {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private SignService signService;
|
||||
|
||||
public void onMessage(SignMessage signMessage) {
|
||||
log.info("onMessage signMessage: {}", JSON.toJSONString(signMessage));
|
||||
|
||||
// 判断该消息是否已经消费过
|
||||
String messStatus = jedisService.hget(RedisKey.mq_sign_status.getKey(), signMessage.getMessId());
|
||||
if (BlankUtil.isBlank(messStatus)) {
|
||||
return;
|
||||
}
|
||||
signService.handlerSign(signMessage);
|
||||
}
|
||||
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
|
||||
import com.accompany.business.service.gamemange.GameManageAccessTicketBizService;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.utils.BlankUtil;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.vo.UserFirstLoginMsgVO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xuanyin.gamematch.constants.GameManageAccessTicketEnum;
|
||||
import com.xuanyin.gamematch.handler.ticketaccessstatey.ITicketAccessStategy;
|
||||
import com.xuanyin.gamematch.handler.ticketaccessstatey.TicketAccessStategyFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.USER_FIRST_LOGIN_TOPIC, consumerGroup = RocketMQConstant.USER_FIRST_LOGIN_CONSUME_GROUP)
|
||||
public class UserFirstLoginMessageMQListener implements RocketMQListener<UserFirstLoginMsgVO> {
|
||||
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
@Autowired
|
||||
private TicketAccessStategyFactory factory;
|
||||
@Autowired
|
||||
private GameManageAccessTicketBizService gameManageAccessTicketBizService;
|
||||
|
||||
public void onMessage(UserFirstLoginMsgVO msg) {
|
||||
log.info("用户首登消息队列, msg: {} ", JSON.toJSONString(msg));
|
||||
// 判断该消息是否已经消费过
|
||||
String messStatus = jedisService.hget(RedisKey.mq_user_first_login_status.getKey(), msg.getUid().toString());
|
||||
if (BlankUtil.isBlank(messStatus)) {
|
||||
return;
|
||||
}
|
||||
handleDayFirstLogin(msg);
|
||||
handleWeekFirstLogin(msg);
|
||||
jedisService.hdel(RedisKey.mq_user_first_login_status.getKey(), msg.getUid().toString());
|
||||
}
|
||||
|
||||
@Async
|
||||
void handleDayFirstLogin(UserFirstLoginMsgVO msg) {
|
||||
if (msg.getIsDayFirstLogin()) {
|
||||
try {
|
||||
log.info("处理用户每日首登 uid {}", msg.getUid());
|
||||
ITicketAccessStategy stategy = factory.getInstance(GameManageAccessTicketEnum.DAY_LOGIN.getValue());
|
||||
stategy.doSend(msg.getUid());
|
||||
gameManageAccessTicketBizService.setTicketAccessInfoToCache(stategy.getAccessType().getValue(), msg.getUid());
|
||||
} catch (ServiceException ignored){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
void handleWeekFirstLogin(UserFirstLoginMsgVO msg) {
|
||||
if (msg.getIsWeekFirstLogin()) {
|
||||
try {
|
||||
log.info("处理用户每周首登 uid {}", msg.getUid());
|
||||
ITicketAccessStategy stategy = factory.getInstance(GameManageAccessTicketEnum.WEEK_LOGIN.getValue());
|
||||
stategy.doSend(msg.getUid());
|
||||
gameManageAccessTicketBizService.setTicketAccessInfoToCache(stategy.getAccessType().getValue(), msg.getUid());
|
||||
} catch (ServiceException ignored){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,45 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.VoiceLikeMessage;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.business.service.voice.VoiceService;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author chucheng
|
||||
* @date 2019-06-05
|
||||
* @description 声音瓶子 喜欢/不喜欢消息监听
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.VOICE_LIKE_TOPIC, consumerGroup = RocketMQConstant.VOICE_LIKE_CONSUME_GROUP)
|
||||
public class VoiceLikeMessageMQListener implements RocketMQListener<VoiceLikeMessage> {
|
||||
|
||||
@Autowired
|
||||
private VoiceService voiceService;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
|
||||
public void onMessage(VoiceLikeMessage message) {
|
||||
log.info("onMessage VoiceLikeMessage: {}", JSON.toJSONString(message));
|
||||
// 判断该消息是否已经消费过
|
||||
String messStatus = jedisService.hget(RedisKey.voice_like_status.getKey(), message.getMessId());
|
||||
if (StringUtils.isBlank(messStatus)) {
|
||||
log.error("handleVoiceLikeMessage status error.message = {}", JSON.toJSONString(message));
|
||||
return;
|
||||
}
|
||||
voiceService.handleVoiceLikeMessage(message);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
package com.accompany.business.service.mq.listener;
|
||||
|
||||
import com.accompany.business.message.YidunIMAntiMessage;
|
||||
import com.accompany.business.service.mq.RocketMQConstant;
|
||||
import com.accompany.business.service.netease.YidunAntiHandleService;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 易盾文本反垃圾消息处理
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = RocketMQConstant.YIDUN_TEXT_ANTI_TOPIC, consumerGroup = RocketMQConstant.YIDUN_TEXT_ANTI_CONSUME_GROUP)
|
||||
public class YidunIMTextAntiMessageMQListener implements RocketMQListener<YidunIMAntiMessage> {
|
||||
|
||||
@Autowired
|
||||
private YidunAntiHandleService yidunAntiHandleService;
|
||||
@Autowired
|
||||
private JedisService jedisService;
|
||||
|
||||
public void onMessage(YidunIMAntiMessage message) {
|
||||
log.info("handle yidun im text anti message {}", JSON.toJSONString(message));
|
||||
String messStatus = jedisService.hget(RedisKey.voice_like_status.getKey(), message.getMessId());
|
||||
if (StringUtils.isBlank(messStatus)) {
|
||||
log.error("handleYidunIMAntiMessage status error.message = {}", JSON.toJSONString(message));
|
||||
return;
|
||||
}
|
||||
yidunAntiHandleService.handlIMTextAnti(message.getChatMsg());
|
||||
// 删除消息标识
|
||||
jedisService.hdel(RedisKey.mq_yindun_im_text_anti_status.getKey(), message.getMessId());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user