Search in sources :

Example 1 with MqSendTypeEnum

use of com.paascloud.provider.model.enums.MqSendTypeEnum 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;
}
Also used : MqProducerStore(com.paascloud.provider.annotation.MqProducerStore) MqMessageData(com.paascloud.provider.model.domain.MqMessageData) MqSendTypeEnum(com.paascloud.provider.model.enums.MqSendTypeEnum) DelayLevelEnum(com.paascloud.provider.model.enums.DelayLevelEnum) TpcBizException(com.paascloud.provider.exceptions.TpcBizException) JoinPoint(org.aspectj.lang.JoinPoint) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around)

Aggregations

MqProducerStore (com.paascloud.provider.annotation.MqProducerStore)1 TpcBizException (com.paascloud.provider.exceptions.TpcBizException)1 MqMessageData (com.paascloud.provider.model.domain.MqMessageData)1 DelayLevelEnum (com.paascloud.provider.model.enums.DelayLevelEnum)1 MqSendTypeEnum (com.paascloud.provider.model.enums.MqSendTypeEnum)1 JoinPoint (org.aspectj.lang.JoinPoint)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 Around (org.aspectj.lang.annotation.Around)1