账单-mq

This commit is contained in:
khalil
2025-01-13 18:04:35 +08:00
parent 50118f3f95
commit c44c272e5d
11 changed files with 241 additions and 58 deletions

View File

@@ -33,6 +33,9 @@ public interface MqConstant {
String ACT_TASK_REWARD_CONSUME_GROUP = "act_task_reward_consume_group";
String LUCKY_24_TOPIC = "lucky_24_topic";
String LUCKY_24_CONSUME_GROUP = "lucky_24_group";
String LUCKY_24_CONSUME_GROUP = "lucky_24_consume_group";
String BILL_RECORD_TOPIC = "bill_record_topic";
String BILL_RECORD_CONSUME_GROUP = "bill_record_consume_group";
}

View File

@@ -0,0 +1,29 @@
package com.accompany.mq.consumer;
import com.accompany.business.message.BillMessage;
import com.accompany.business.service.gift.BillMessageService;
import com.accompany.mq.constant.MqConstant;
import com.accompany.mq.listener.AbstractMessageListener;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
@RocketMQMessageListener(topic = MqConstant.BILL_RECORD_TOPIC, consumerGroup = MqConstant.BILL_RECORD_CONSUME_GROUP, consumeMode = ConsumeMode.ORDERLY)
public class BillMessageConsumer extends AbstractMessageListener<BillMessage> {
@Autowired
private BillMessageService billMessageService;
@Override
public void onMessage(BillMessage billMessage) {
log.info("onMessage billMessage: {}", billMessage.toString());
billMessageService.handleBillMessage(billMessage);
}
}

View File

@@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@ConditionalOnProperty(name = "spring.application.name", havingValue = "web")
//@RocketMQMessageListener(topic = MqConstant.LUCKY_24_TOPIC, consumerGroup = MqConstant.LUCKY_24_CONSUME_GROUP, consumeMode = ConsumeMode.ORDERLY)
@RocketMQMessageListener(topic = MqConstant.LUCKY_24_TOPIC, consumerGroup = MqConstant.LUCKY_24_CONSUME_GROUP)
public class Lucky24MessageConsumer extends AbstractMessageListener<Lucky24Message> {