Commit dc1e48c4 authored by dingzhiwei's avatar dingzhiwei
Browse files

优化阿里云rocketMQ

parent 0c54ea2f
...@@ -25,7 +25,7 @@ public abstract class AbstractAliYunRocketMQReceiver implements IMQMsgReceiver, ...@@ -25,7 +25,7 @@ public abstract class AbstractAliYunRocketMQReceiver implements IMQMsgReceiver,
* *
* @return * @return
*/ */
public abstract String getCusumerName(); public abstract String getConsumerName();
/** /**
* 发送类型 * 发送类型
...@@ -48,16 +48,16 @@ public abstract class AbstractAliYunRocketMQReceiver implements IMQMsgReceiver, ...@@ -48,16 +48,16 @@ public abstract class AbstractAliYunRocketMQReceiver implements IMQMsgReceiver,
public Action consume(Message message, ConsumeContext context) { public Action consume(Message message, ConsumeContext context) {
try { try {
receiveMsg(new String(message.getBody())); 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; return Action.CommitMessage;
} catch (Exception e) { } 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; return Action.ReconsumeLater;
} }
}); });
consumerClient.start(); consumerClient.start();
log.info("初始化[{}]消费者topic: {},tag: {}成功", getCusumerName(), this.getMQName(), AliYunRocketMQFactory.defaultTag); log.info("初始化[{}]消费者topic: {},tag: {}成功", getConsumerName(), this.getMQName(), AliYunRocketMQFactory.defaultTag);
} }
} }
package com.jeequan.jeepay.components.mq.vender.aliyunrocketmq; package com.jeequan.jeepay.components.mq.vender.aliyunrocketmq;
import com.aliyun.openservices.ons.api.*; import com.aliyun.openservices.ons.api.*;
import com.jeequan.jeepay.components.mq.constant.MQVenderCS;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Properties; import java.util.Properties;
@Service @Service
@ConditionalOnProperty(name = MQVenderCS.YML_VENDER_KEY, havingValue = MQVenderCS.ALIYUN_ROCKET_MQ)
public class AliYunRocketMQFactory { public class AliYunRocketMQFactory {
public static final String defaultTag = "Default"; public static final String defaultTag = "Default";
......
...@@ -19,10 +19,12 @@ import com.alibaba.fastjson.JSONObject; ...@@ -19,10 +19,12 @@ import com.alibaba.fastjson.JSONObject;
import com.aliyun.openservices.ons.api.Message; import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.Producer; import com.aliyun.openservices.ons.api.Producer;
import com.aliyun.openservices.ons.api.SendResult; 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.model.AbstractMQ;
import com.jeequan.jeepay.components.mq.vender.IMQSender; import com.jeequan.jeepay.components.mq.vender.IMQSender;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -34,6 +36,7 @@ import java.util.TreeMap; ...@@ -34,6 +36,7 @@ import java.util.TreeMap;
*/ */
@Slf4j @Slf4j
@Component @Component
@ConditionalOnProperty(name = MQVenderCS.YML_VENDER_KEY, havingValue = MQVenderCS.ALIYUN_ROCKET_MQ)
public class AliYunRocketMQSender implements IMQSender { public class AliYunRocketMQSender implements IMQSender {
private static final List<Integer> DELAY_TIME_LEVEL = new ArrayList<>(); private static final List<Integer> DELAY_TIME_LEVEL = new ArrayList<>();
......
...@@ -36,7 +36,8 @@ import org.springframework.stereotype.Component; ...@@ -36,7 +36,8 @@ import org.springframework.stereotype.Component;
@Slf4j @Slf4j
public class CleanMchLoginAuthCacheAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver { public class CleanMchLoginAuthCacheAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "清除商户登录消息"; private static final String CONSUMER_NAME = "清除商户登录消息";
@Autowired @Autowired
private CleanMchLoginAuthCacheMQ.IMQReceiver mqReceiver; private CleanMchLoginAuthCacheMQ.IMQReceiver mqReceiver;
...@@ -65,8 +66,8 @@ public class CleanMchLoginAuthCacheAliYunRocketMQReceiver extends AbstractAliYun ...@@ -65,8 +66,8 @@ public class CleanMchLoginAuthCacheAliYunRocketMQReceiver extends AbstractAliYun
* @return * @return
*/ */
@Override @Override
public String getCusumerName() { public String getConsumerName() {
return cusumerName; return CONSUMER_NAME;
} }
} }
...@@ -34,7 +34,8 @@ import org.springframework.stereotype.Component; ...@@ -34,7 +34,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(PayOrderDivisionMQ.IMQReceiver.class) @ConditionalOnBean(PayOrderDivisionMQ.IMQReceiver.class)
public class PayOrderDivisionAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver { public class PayOrderDivisionAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "支付订单分账消息"; private static final String CONSUMER_NAME = "支付订单分账消息";
@Autowired @Autowired
private PayOrderDivisionMQ.IMQReceiver mqReceiver; private PayOrderDivisionMQ.IMQReceiver mqReceiver;
...@@ -62,8 +63,8 @@ public class PayOrderDivisionAliYunRocketMQReceiver extends AbstractAliYunRocket ...@@ -62,8 +63,8 @@ public class PayOrderDivisionAliYunRocketMQReceiver extends AbstractAliYunRocket
* @return * @return
*/ */
@Override @Override
public String getCusumerName() { public String getConsumerName() {
return cusumerName; return CONSUMER_NAME;
} }
} }
...@@ -36,7 +36,8 @@ import org.springframework.stereotype.Component; ...@@ -36,7 +36,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(PayOrderMchNotifyMQ.IMQReceiver.class) @ConditionalOnBean(PayOrderMchNotifyMQ.IMQReceiver.class)
public class PayOrderMchNotifyAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver { public class PayOrderMchNotifyAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "支付订单商户消息"; private static final String CONSUMER_NAME = "支付订单商户消息";
@Autowired @Autowired
private PayOrderMchNotifyMQ.IMQReceiver mqReceiver; private PayOrderMchNotifyMQ.IMQReceiver mqReceiver;
...@@ -65,8 +66,8 @@ public class PayOrderMchNotifyAliYunRocketMQReceiver extends AbstractAliYunRocke ...@@ -65,8 +66,8 @@ public class PayOrderMchNotifyAliYunRocketMQReceiver extends AbstractAliYunRocke
* @return * @return
*/ */
@Override @Override
public String getCusumerName() { public String getConsumerName() {
return cusumerName; return CONSUMER_NAME;
} }
} }
...@@ -36,7 +36,8 @@ import org.springframework.stereotype.Component; ...@@ -36,7 +36,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(PayOrderReissueMQ.IMQReceiver.class) @ConditionalOnBean(PayOrderReissueMQ.IMQReceiver.class)
public class PayOrderReissueAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver { public class PayOrderReissueAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "支付订单补单消息"; private static final String CONSUMER_NAME = "支付订单补单消息";
@Autowired @Autowired
private PayOrderReissueMQ.IMQReceiver mqReceiver; private PayOrderReissueMQ.IMQReceiver mqReceiver;
...@@ -65,7 +66,7 @@ public class PayOrderReissueAliYunRocketMQReceiver extends AbstractAliYunRocketM ...@@ -65,7 +66,7 @@ public class PayOrderReissueAliYunRocketMQReceiver extends AbstractAliYunRocketM
* @return * @return
*/ */
@Override @Override
public String getCusumerName() { public String getConsumerName() {
return cusumerName; return CONSUMER_NAME;
} }
} }
...@@ -35,7 +35,8 @@ import org.springframework.stereotype.Component; ...@@ -35,7 +35,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(ResetAppConfigMQ.IMQReceiver.class) @ConditionalOnBean(ResetAppConfigMQ.IMQReceiver.class)
public class ResetAppConfigAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver { public class ResetAppConfigAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "更新系统配置参数消息"; private static final String CONSUMER_NAME = "更新系统配置参数消息";
@Autowired @Autowired
private ResetAppConfigMQ.IMQReceiver mqReceiver; private ResetAppConfigMQ.IMQReceiver mqReceiver;
...@@ -70,8 +71,8 @@ public class ResetAppConfigAliYunRocketMQReceiver extends AbstractAliYunRocketMQ ...@@ -70,8 +71,8 @@ public class ResetAppConfigAliYunRocketMQReceiver extends AbstractAliYunRocketMQ
* @return * @return
*/ */
@Override @Override
public String getCusumerName() { public String getConsumerName() {
return cusumerName; return CONSUMER_NAME;
} }
/** /**
......
...@@ -35,7 +35,8 @@ import org.springframework.stereotype.Component; ...@@ -35,7 +35,8 @@ import org.springframework.stereotype.Component;
@ConditionalOnBean(ResetIsvMchAppInfoConfigMQ.IMQReceiver.class) @ConditionalOnBean(ResetIsvMchAppInfoConfigMQ.IMQReceiver.class)
public class ResetIsvMchAppInfoAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver { public class ResetIsvMchAppInfoAliYunRocketMQReceiver extends AbstractAliYunRocketMQReceiver {
private static final String cusumerName = "更新服务商/商户/商户应用配置信息消息"; private static final String CONSUMER_NAME = "更新服务商/商户/商户应用配置信息消息";
@Autowired @Autowired
private ResetIsvMchAppInfoConfigMQ.IMQReceiver mqReceiver; private ResetIsvMchAppInfoConfigMQ.IMQReceiver mqReceiver;
...@@ -70,8 +71,8 @@ public class ResetIsvMchAppInfoAliYunRocketMQReceiver extends AbstractAliYunRock ...@@ -70,8 +71,8 @@ public class ResetIsvMchAppInfoAliYunRocketMQReceiver extends AbstractAliYunRock
* @return * @return
*/ */
@Override @Override
public String getCusumerName() { public String getConsumerName() {
return cusumerName; return CONSUMER_NAME;
} }
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment