优化阿里云rocketMQ

This commit is contained in:
dingzhiwei 2021-12-16 19:50:50 +08:00
parent 0c54ea2f96
commit dc1e48c410
9 changed files with 34 additions and 22 deletions

View File

@ -25,7 +25,7 @@ public abstract class AbstractAliYunRocketMQReceiver implements IMQMsgReceiver,
*
* @return
*/
public abstract String getCusumerName();
public abstract String getConsumerName();
/**
* 发送类型
@ -48,16 +48,16 @@ public abstract class AbstractAliYunRocketMQReceiver implements IMQMsgReceiver,
public Action consume(Message message, ConsumeContext context) {
try {
receiveMsg(new String(message.getBody()));
log.info("【{}】MQ消息消费成功topic:{}, messageId:{}", getCusumerName(), message.getTopic(), message.getMsgID());
log.info("【{}】MQ消息消费成功topic:{}, messageId:{}", getConsumerName(), message.getTopic(), message.getMsgID());
return Action.CommitMessage;
} catch (Exception e) {
log.error("【{}】MQ消息消费失败topic:{}, messageId:{}", getCusumerName(), message.getTopic(), message.getMsgID(), e);
log.error("【{}】MQ消息消费失败topic:{}, messageId:{}", getConsumerName(), message.getTopic(), message.getMsgID(), e);
}
return Action.ReconsumeLater;
}
});
consumerClient.start();
log.info("初始化[{}]消费者topic: {},tag: {}成功", getCusumerName(), this.getMQName(), AliYunRocketMQFactory.defaultTag);
log.info("初始化[{}]消费者topic: {},tag: {}成功", getConsumerName(), this.getMQName(), AliYunRocketMQFactory.defaultTag);
}
}

View File

@ -1,14 +1,17 @@
package com.jeequan.jeepay.components.mq.vender.aliyunrocketmq;
import com.aliyun.openservices.ons.api.*;
import com.jeequan.jeepay.components.mq.constant.MQVenderCS;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import java.util.Properties;
@Service
@ConditionalOnProperty(name = MQVenderCS.YML_VENDER_KEY, havingValue = MQVenderCS.ALIYUN_ROCKET_MQ)
public class AliYunRocketMQFactory {
public static final String defaultTag = "Default";

View File

@ -19,10 +19,12 @@ import com.alibaba.fastjson.JSONObject;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.Producer;
import com.aliyun.openservices.ons.api.SendResult;
import com.jeequan.jeepay.components.mq.constant.MQVenderCS;
import com.jeequan.jeepay.components.mq.model.AbstractMQ;
import com.jeequan.jeepay.components.mq.vender.IMQSender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
@ -34,6 +36,7 @@ import java.util.TreeMap;
*/
@Slf4j
@Component
@ConditionalOnProperty(name = MQVenderCS.YML_VENDER_KEY, havingValue = MQVenderCS.ALIYUN_ROCKET_MQ)
public class AliYunRocketMQSender implements IMQSender {
private static final List<Integer> DELAY_TIME_LEVEL = new ArrayList<>();

View File

@ -36,7 +36,8 @@ import org.springframework.stereotype.Component;
@Slf4j
public class CleanMchLoginAuthCacheAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "清除商户登录消息";
private static final String CONSUMER_NAME = "清除商户登录消息";
@Autowired
private CleanMchLoginAuthCacheMQ.IMQReceiver mqReceiver;
@ -65,8 +66,8 @@ public class CleanMchLoginAuthCacheAliYunRocketMQReceiver extends AbstractAliYun
* @return
*/
@Override
public String getCusumerName() {
return cusumerName;
public String getConsumerName() {
return CONSUMER_NAME;
}
}

View File

@ -34,7 +34,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(PayOrderDivisionMQ.IMQReceiver.class)
public class PayOrderDivisionAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "支付订单分账消息";
private static final String CONSUMER_NAME = "支付订单分账消息";
@Autowired
private PayOrderDivisionMQ.IMQReceiver mqReceiver;
@ -62,8 +63,8 @@ public class PayOrderDivisionAliYunRocketMQReceiver extends AbstractAliYunRocket
* @return
*/
@Override
public String getCusumerName() {
return cusumerName;
public String getConsumerName() {
return CONSUMER_NAME;
}
}

View File

@ -36,7 +36,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(PayOrderMchNotifyMQ.IMQReceiver.class)
public class PayOrderMchNotifyAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "支付订单商户消息";
private static final String CONSUMER_NAME = "支付订单商户消息";
@Autowired
private PayOrderMchNotifyMQ.IMQReceiver mqReceiver;
@ -65,8 +66,8 @@ public class PayOrderMchNotifyAliYunRocketMQReceiver extends AbstractAliYunRocke
* @return
*/
@Override
public String getCusumerName() {
return cusumerName;
public String getConsumerName() {
return CONSUMER_NAME;
}
}

View File

@ -36,7 +36,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(PayOrderReissueMQ.IMQReceiver.class)
public class PayOrderReissueAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "支付订单补单消息";
private static final String CONSUMER_NAME = "支付订单补单消息";
@Autowired
private PayOrderReissueMQ.IMQReceiver mqReceiver;
@ -65,7 +66,7 @@ public class PayOrderReissueAliYunRocketMQReceiver extends AbstractAliYunRocketM
* @return
*/
@Override
public String getCusumerName() {
return cusumerName;
public String getConsumerName() {
return CONSUMER_NAME;
}
}

View File

@ -35,7 +35,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(ResetAppConfigMQ.IMQReceiver.class)
public class ResetAppConfigAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "更新系统配置参数消息";
private static final String CONSUMER_NAME = "更新系统配置参数消息";
@Autowired
private ResetAppConfigMQ.IMQReceiver mqReceiver;
@ -70,8 +71,8 @@ public class ResetAppConfigAliYunRocketMQReceiver extends AbstractAliYunRocketMQ
* @return
*/
@Override
public String getCusumerName() {
return cusumerName;
public String getConsumerName() {
return CONSUMER_NAME;
}
/**

View File

@ -35,7 +35,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(ResetIsvMchAppInfoConfigMQ.IMQReceiver.class)
public class ResetIsvMchAppInfoAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "更新服务商/商户/商户应用配置信息消息";
private static final String CONSUMER_NAME = "更新服务商/商户/商户应用配置信息消息";
@Autowired
private ResetIsvMchAppInfoConfigMQ.IMQReceiver mqReceiver;
@ -70,8 +71,8 @@ public class ResetIsvMchAppInfoAliYunRocketMQReceiver extends AbstractAliYunRock
* @return
*/
@Override
public String getCusumerName() {
return cusumerName;
public String getConsumerName() {
return CONSUMER_NAME;
}
/**