use of com.paascloud.provider.exceptions.TpcBizException in project paascloud-master by paascloud.
the class MqMessageServiceImpl method saveAndConfirmFinishMessage.
@Override
public void saveAndConfirmFinishMessage(String cid, String messageKey) {
Wrapper wrapper = tpcMqMessageFeignApi.confirmConsumedMessage(cid, messageKey);
log.info("tpcMqMessageFeignApi.confirmReceiveMessage result={}", wrapper);
if (wrapper == null) {
throw new TpcBizException(ErrorCodeEnum.GL99990002);
}
if (wrapper.error()) {
throw new TpcBizException(ErrorCodeEnum.TPC10050004, wrapper.getMessage(), messageKey);
}
}
use of com.paascloud.provider.exceptions.TpcBizException in project paascloud-master by paascloud.
the class MqMessageServiceImpl method confirmAndSendMessage.
@Override
public void confirmAndSendMessage(String messageKey) {
// 发送确认消息给消息中心
try {
Wrapper wrapper = tpcMqMessageFeignApi.confirmAndSendMessage(messageKey);
if (wrapper == null) {
throw new TpcBizException(ErrorCodeEnum.GL99990002);
}
if (wrapper.error()) {
throw new TpcBizException(ErrorCodeEnum.TPC10050004, wrapper.getMessage(), messageKey);
}
log.info("<== saveMqProducerMessage - 存储并发送消息给消息中心成功. messageKey={}", messageKey);
} catch (Exception e) {
log.error("<== saveMqProducerMessage - 存储并发送消息给消息中心失败. messageKey={}", messageKey, e);
}
}
use of com.paascloud.provider.exceptions.TpcBizException 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;
}
use of com.paascloud.provider.exceptions.TpcBizException in project paascloud-master by paascloud.
the class RocketMqProducer method sendSimpleMessage.
public static SendResult sendSimpleMessage(String body, String topic, String tag, String key, String pid, Integer delayLevel) {
if (delayLevel == null) {
delayLevel = 0;
}
Message message = MqMessage.checkMessage(body, topic, tag, key);
if (delayLevel < 0 || delayLevel > GlobalConstant.Number.EIGHTEEN_INT) {
throw new TpcBizException(ErrorCodeEnum.TPC100500013, topic, key);
}
message.setDelayTimeLevel(delayLevel);
return retrySendMessage(pid, message);
}
use of com.paascloud.provider.exceptions.TpcBizException in project paascloud-master by paascloud.
the class RocketMqProducer method retrySendMessage.
private static SendResult retrySendMessage(String pid, Message msg) {
int iniCount = 1;
SendResult result;
while (true) {
try {
result = MqProducerBeanFactory.getBean(pid).send(msg);
break;
} catch (Exception e) {
log.error("发送消息失败:", e);
if (iniCount++ >= PRODUCER_RETRY_TIMES) {
throw new TpcBizException(ErrorCodeEnum.TPC100500014, msg.getTopic(), msg.getKeys());
}
}
}
log.info("<== 发送MQ SendResult={}", result);
return result;
}
Aggregations