Search in sources :

Example 11 with TpcBizException

use of com.paascloud.provider.exceptions.TpcBizException in project paascloud-master by paascloud.

the class TpcMqMessageServiceImpl method confirmAndSendMessage.

@Override
public void confirmAndSendMessage(String messageKey) {
    final TpcMqMessage message = tpcMqMessageMapper.getByMessageKey(messageKey);
    if (message == null) {
        throw new TpcBizException(ErrorCodeEnum.TPC10050002);
    }
    TpcMqMessage update = new TpcMqMessage();
    update.setMessageStatus(MqSendStatusEnum.SENDING.sendStatus());
    update.setId(message.getId());
    update.setUpdateTime(new Date());
    tpcMqMessageMapper.updateByPrimaryKeySelective(update);
    // 创建消费待确认列表
    this.createMqConfirmListByTopic(message.getMessageTopic(), message.getId(), message.getMessageKey());
    // 直接发送消息
    this.directSendMessage(message.getMessageBody(), message.getMessageTopic(), message.getMessageTag(), message.getMessageKey(), message.getProducerGroup(), message.getDelayLevel());
}
Also used : TpcMqMessage(com.paascloud.provider.model.domain.TpcMqMessage) TpcBizException(com.paascloud.provider.exceptions.TpcBizException) Date(java.util.Date)

Example 12 with TpcBizException

use of com.paascloud.provider.exceptions.TpcBizException in project paascloud-master by paascloud.

the class TpcMqMessageServiceImpl method createMqConfirmListByTopic.

@Override
public void createMqConfirmListByTopic(final String topic, final Long messageId, final String messageKey) {
    List<TpcMqConfirm> list = Lists.newArrayList();
    TpcMqConfirm tpcMqConfirm;
    List<String> consumerGroupList = tpcMqConsumerService.listConsumerGroupByTopic(topic);
    if (PublicUtil.isEmpty(consumerGroupList)) {
        throw new TpcBizException(ErrorCodeEnum.TPC100500010, topic);
    }
    for (final String cid : consumerGroupList) {
        tpcMqConfirm = new TpcMqConfirm(UniqueIdGenerator.generateId(), messageId, messageKey, cid);
        list.add(tpcMqConfirm);
    }
    tpcMqConfirmMapper.batchCreateMqConfirm(list);
}
Also used : TpcMqConfirm(com.paascloud.provider.model.domain.TpcMqConfirm) TpcBizException(com.paascloud.provider.exceptions.TpcBizException)

Example 13 with TpcBizException

use of com.paascloud.provider.exceptions.TpcBizException in project paascloud-master by paascloud.

the class TpcMqMessageServiceImpl method resendMessageByMessageId.

@Override
public void resendMessageByMessageId(Long messageId) {
    final TpcMqMessage message = tpcMqMessageMapper.selectByPrimaryKey(messageId);
    if (message == null) {
        throw new TpcBizException(ErrorCodeEnum.TPC10050006);
    }
    this.resendMessage(message);
}
Also used : TpcMqMessage(com.paascloud.provider.model.domain.TpcMqMessage) TpcBizException(com.paascloud.provider.exceptions.TpcBizException)

Aggregations

TpcBizException (com.paascloud.provider.exceptions.TpcBizException)13 TpcMqMessage (com.paascloud.provider.model.domain.TpcMqMessage)5 Wrapper (com.paascloud.wrapper.Wrapper)3 Date (java.util.Date)3 MqMessageData (com.paascloud.provider.model.domain.MqMessageData)2 Around (org.aspectj.lang.annotation.Around)2 ModelMapper (org.modelmapper.ModelMapper)2 MqMessage (com.paascloud.core.mq.MqMessage)1 MqConsumerStore (com.paascloud.provider.annotation.MqConsumerStore)1 MqProducerStore (com.paascloud.provider.annotation.MqProducerStore)1 TpcMqConfirm (com.paascloud.provider.model.domain.TpcMqConfirm)1 DelayLevelEnum (com.paascloud.provider.model.enums.DelayLevelEnum)1 MqSendTypeEnum (com.paascloud.provider.model.enums.MqSendTypeEnum)1 List (java.util.List)1 SendResult (org.apache.rocketmq.client.producer.SendResult)1 Message (org.apache.rocketmq.common.message.Message)1 MessageExt (org.apache.rocketmq.common.message.MessageExt)1 JoinPoint (org.aspectj.lang.JoinPoint)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1 Transactional (org.springframework.transaction.annotation.Transactional)1