小游戏推送MQ
This commit is contained in:
@@ -41,4 +41,9 @@ public interface MqConstant {
|
||||
String MINI_GAME_MATCH_ROUND_TOPIC = "mini_game_match_round_topic";
|
||||
String MINI_GAME_MATCH_ROUND_CONSUME_GROUP = "mini_game_match_round_consume_group";
|
||||
|
||||
String GAME_MSG_PUSH_TOPIC = "game_msg_push_topic";
|
||||
String GAME_MSG_PUSH_CONSUME_GROUP = "game_msg_push_consume_group";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,40 @@
|
||||
package com.accompany.mq.consumer;
|
||||
|
||||
import com.accompany.business.enums.resource.ResourceCodeEnum;
|
||||
import com.accompany.business.event.miniGame.MiniGameChangeCurrencyEvent;
|
||||
import com.accompany.business.message.BillMessage;
|
||||
import com.accompany.business.message.GameMsgMessage;
|
||||
import com.accompany.business.service.game.BaseGameMessageService;
|
||||
import com.accompany.business.service.gift.BillMessageService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.mq.constant.MqConstant;
|
||||
import com.accompany.mq.listener.AbstractMessageListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
|
||||
@RocketMQMessageListener(topic = MqConstant.GAME_MSG_PUSH_TOPIC, consumerGroup = MqConstant.GAME_MSG_PUSH_CONSUME_GROUP)
|
||||
public class GameMsgPushMessageConsumer extends AbstractMessageListener<GameMsgMessage> {
|
||||
|
||||
@Autowired
|
||||
private BaseGameMessageService baseGameMessageService;
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void onMessage(GameMsgMessage gameMsgMessage) {
|
||||
log.info("onMessage gameMsgMessage: {}", gameMsgMessage.toString());
|
||||
if (gameMsgMessage.getPushScreen()) {
|
||||
baseGameMessageService.sendGameMessage(gameMsgMessage.getGameId(), gameMsgMessage.getRoomUid(), gameMsgMessage.getUid(), Math.abs(gameMsgMessage.getCoin()),
|
||||
gameMsgMessage.getResourceCodeEnum(), gameMsgMessage.getConfigId());
|
||||
}
|
||||
applicationContext.publishEvent(new MiniGameChangeCurrencyEvent(gameMsgMessage));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user