use of com.paascloud.provider.model.domain.MqMessageData in project paascloud-master by paascloud.
the class SmsProducer method sendSmsCodeMq.
public MqMessageData sendSmsCodeMq(SmsMessage smsMessage, AliyunSmsConstants.SmsTempletEnum templetEnum) {
log.info("sendSmsCodeMq - 发送短信验证码. smsMessage={}", smsMessage);
String msgBody;
try {
PcSendSmsRequest request = new PcSendSmsRequest();
Map<String, String> map = Maps.newHashMap();
// 模板参数
String smsParamName = templetEnum.getSmsParamName();
// 模板编码
String templetCode = templetEnum.getTempletCode();
// 替换模板验证码
map.put(smsParamName, smsMessage.getSmsCode());
String param = JSON.toJSONString(map);
request.setPhoneNumbers(smsMessage.getMobileNo());
request.setTemplateCode(templetCode);
request.setTemplateParam(param);
request.setOutId(smsMessage.getOutId());
msgBody = JSON.toJSONString(request);
} catch (Exception e) {
log.error("发送短信验证码 smsMessage转换为json字符串失败", e);
throw new UacBizException(ErrorCodeEnum.UAC10011022);
}
String topic = AliyunMqTopicConstants.MqTopicEnum.SEND_SMS_TOPIC.getTopic();
String tag = AliyunMqTopicConstants.MqTagEnum.REGISTER_USER_AUTH_CODE.getTag();
String key = RedisKeyUtil.createMqKey(topic, tag, smsMessage.getMobileNo(), msgBody);
return new MqMessageData(msgBody, topic, tag, key);
}
use of com.paascloud.provider.model.domain.MqMessageData in project paascloud-master by paascloud.
the class MqConsumerStoreAspect method processMqConsumerStoreJoinPoint.
/**
* Add exe time method object.
*
* @param joinPoint the join point
*
* @return the object
*
* @throws Throwable the throwable
*/
@Around(value = "mqConsumerStoreAnnotationPointcut()")
public Object processMqConsumerStoreJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
log.info("processMqConsumerStoreJoinPoint - 线程id={}", Thread.currentThread().getId());
Object result;
long startTime = System.currentTimeMillis();
Object[] args = joinPoint.getArgs();
MqConsumerStore annotation = getAnnotation(joinPoint);
boolean isStorePreStatus = annotation.storePreStatus();
List<MessageExt> messageExtList;
if (args == null || args.length == 0) {
throw new TpcBizException(ErrorCodeEnum.TPC10050005);
}
if (!(args[0] instanceof List)) {
throw new TpcBizException(ErrorCodeEnum.GL99990001);
}
try {
messageExtList = (List<MessageExt>) args[0];
} catch (Exception e) {
log.error("processMqConsumerStoreJoinPoint={}", e.getMessage(), e);
throw new TpcBizException(ErrorCodeEnum.GL99990001);
}
MqMessageData dto = this.getTpcMqMessageDto(messageExtList.get(0));
final String messageKey = dto.getMessageKey();
if (isStorePreStatus) {
mqMessageService.confirmReceiveMessage(consumerGroup, dto);
}
String methodName = joinPoint.getSignature().getName();
try {
result = joinPoint.proceed();
log.info("result={}", result);
if (CONSUME_SUCCESS.equals(result.toString())) {
mqMessageService.saveAndConfirmFinishMessage(consumerGroup, messageKey);
}
} catch (Exception e) {
log.error("发送可靠消息, 目标方法[{}], 出现异常={}", methodName, e.getMessage(), e);
throw e;
} finally {
log.info("发送可靠消息 目标方法[{}], 总耗时={}", methodName, System.currentTimeMillis() - startTime);
}
return result;
}
use of com.paascloud.provider.model.domain.MqMessageData in project paascloud-master by paascloud.
the class MqConsumerStoreAspect method getTpcMqMessageDto.
private MqMessageData getTpcMqMessageDto(MessageExt messageExt) {
MqMessageData data = new MqMessageData();
data.setMessageBody(new String(messageExt.getBody()));
data.setMessageKey(messageExt.getKeys());
data.setMessageTag(messageExt.getTags());
data.setMessageTopic(messageExt.getTopic());
data.setMessageType(MqMessageTypeEnum.CONSUMER_MESSAGE.messageType());
return data;
}
use of com.paascloud.provider.model.domain.MqMessageData in project paascloud-master by paascloud.
the class MdcProductServiceImpl method deleteProductById.
@Override
public void deleteProductById(final Long id) {
MdcProduct product = mdcProductMapper.selectByPrimaryKey(id);
if (product != null) {
String body = product.getProductCode();
String topic = AliyunMqTopicConstants.MqTagEnum.DELETE_ATTACHMENT.getTopic();
String tag = AliyunMqTopicConstants.MqTagEnum.DELETE_ATTACHMENT.getTag();
String key = RedisKeyUtil.createMqKey(topic, tag, product.getProductCode(), body);
MqMessageData mqMessageData = new MqMessageData(body, topic, tag, key);
mdcProductManager.deleteProduct(mqMessageData, id);
}
}
use of com.paascloud.provider.model.domain.MqMessageData in project paascloud-master by paascloud.
the class MqProducerStoreAspect method processMqProducerStoreJoinPoint.
/**
* Add exe time method object.
*
* @param joinPoint the join point
*
* @return the object
*/
@Around(value = "mqProducerStoreAnnotationPointcut()")
public Object processMqProducerStoreJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
log.info("processMqProducerStoreJoinPoint - 线程id={}", Thread.currentThread().getId());
Object result;
Object[] args = joinPoint.getArgs();
MqProducerStore annotation = getAnnotation(joinPoint);
MqSendTypeEnum type = annotation.sendType();
int orderType = annotation.orderType().orderType();
DelayLevelEnum delayLevelEnum = annotation.delayLevel();
if (args.length == 0) {
throw new TpcBizException(ErrorCodeEnum.TPC10050005);
}
MqMessageData domain = null;
for (Object object : args) {
if (object instanceof MqMessageData) {
domain = (MqMessageData) object;
break;
}
}
if (domain == null) {
throw new TpcBizException(ErrorCodeEnum.TPC10050005);
}
domain.setOrderType(orderType);
domain.setProducerGroup(producerGroup);
if (type == MqSendTypeEnum.WAIT_CONFIRM) {
if (delayLevelEnum != DelayLevelEnum.ZERO) {
domain.setDelayLevel(delayLevelEnum.delayLevel());
}
mqMessageService.saveWaitConfirmMessage(domain);
}
result = joinPoint.proceed();
if (type == MqSendTypeEnum.SAVE_AND_SEND) {
mqMessageService.saveAndSendMessage(domain);
} else if (type == MqSendTypeEnum.DIRECT_SEND) {
mqMessageService.directSendMessage(domain);
} else {
mqMessageService.confirmAndSendMessage(domain.getMessageKey());
}
return result;
}
Aggregations