|
|
|
@@ -1,8 +1,7 @@ |
|
|
|
package com.iformall.mq; |
|
|
|
|
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.enums.EnumMsgRecordStatus; |
|
|
|
import com.iformall.enums.EnumMsgRecordType; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.mapper.WxMsgRecordMapper; |
|
|
|
import com.iformall.service.impl.SendCallBackSmsServiceImpl; |
|
|
|
import com.iformall.service.impl.SendEmailServiceImpl; |
|
|
|
@@ -30,6 +29,8 @@ public class MqBaseConsumer { |
|
|
|
private SendEmailServiceImpl sendEmailService; |
|
|
|
@Autowired |
|
|
|
private SendSmartAppMsgServiceImpl sendSmartAppMsgService; |
|
|
|
@Autowired |
|
|
|
private MqBaseProducer mqBaseProducer; |
|
|
|
|
|
|
|
public void doMessage(String message) { |
|
|
|
log.info("received message: {}", message); |
|
|
|
@@ -39,12 +40,16 @@ public class MqBaseConsumer { |
|
|
|
baseMsg = (BaseMsg)JsonUtil.readValue(message,BaseMsg.class); |
|
|
|
|
|
|
|
if(EnumMsgRecordType.SMS.getCode().equals(baseMsg.getMsgType())){ |
|
|
|
//短信 |
|
|
|
sendSmsService.send((WxMsgRecord)JsonUtil.readValue(message,WxMsgRecord.class)); |
|
|
|
}else if(EnumMsgRecordType.SMS_CALLBACK.getCode().equals(baseMsg.getMsgType())){ |
|
|
|
//业务短信 |
|
|
|
sendCallBackSmsService.send((WxMsg)JsonUtil.readValue(message,WxMsg.class)); |
|
|
|
}else if(EnumMsgRecordType.EMAIL.getCode().equals(baseMsg.getMsgType())){ |
|
|
|
//邮件 |
|
|
|
sendEmailService.send((MailMsg)JsonUtil.readValue(message,MailMsg.class)); |
|
|
|
}else if(EnumMsgRecordType.SMART_APP.getCode().equals(baseMsg.getMsgType())){ |
|
|
|
//微信小程序 |
|
|
|
sendSmartAppMsgService.send((SmartAppMsg)JsonUtil.readValue(message,SmartAppMsg.class)); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -52,9 +57,14 @@ public class MqBaseConsumer { |
|
|
|
wxMsgRecordMapper.update(baseMsg); |
|
|
|
}catch (Exception e){ |
|
|
|
if(null != baseMsg){ |
|
|
|
baseMsg.setStatusMessage(e.getMessage()); |
|
|
|
baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); |
|
|
|
wxMsgRecordMapper.update(baseMsg); |
|
|
|
if(baseMsg.getDelayTimeLevel() < 3){ |
|
|
|
baseMsg.setDelayTimeLevel(3); //10s后重试 |
|
|
|
mqBaseProducer.sendMessage(baseMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); |
|
|
|
}else{ |
|
|
|
baseMsg.setStatusMessage(e.getMessage()); |
|
|
|
baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); |
|
|
|
wxMsgRecordMapper.update(baseMsg); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|