From 33d260a26d4e274628d82b2c1f716edc430adeb7 Mon Sep 17 00:00:00 2001 From: luozukai Date: Wed, 17 Apr 2019 19:18:09 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=AE=A1=E6=89=B9=E6=B5=81][=E4=BF=AE?= =?UTF-8?q?=E6=94=B9][=E5=AE=8C=E5=96=84=E8=B4=A6=E5=8D=95=E5=AE=A1?= =?UTF-8?q?=E6=89=B9]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/mq/MqBaseConsumer.java | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java b/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java index 7c4a589c8..eca04fa9c 100644 --- a/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java +++ b/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java @@ -35,54 +35,54 @@ public class MqBaseConsumer { public void doMessage(String message) { log.info("received message: {}", message); -// BaseMsg baseMsg = null; -// -// try { -// 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)); -// } else if(EnumMsgRecordType.PUBLIC.getCode().equals(baseMsg.getMsgType())) { -// //公众号-模板消息 -// sendMpMsgService.send((MpAppMsg)JsonUtil.readValue(message,MpAppMsg.class)); -// } else if(EnumMsgRecordType.SMART_APP_UNIFORM.getCode().equals(baseMsg.getMsgType())) { -// //微信小程序-统一消息 -// sendWeappUniformMsgService.send((AppUniformMsg)JsonUtil.readValue(message,AppUniformMsg.class)); -// } -// baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); -// wxMsgRecordMapper.update(baseMsg); -// }catch (Exception e){ -// try { -// log.error("consum received error:{} ", e.getMessage()); -// log.error("consum received error: ", e); -// //baseMsg.setStatusMessage(e.getMessage()); -// baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); -// wxMsgRecordMapper.update(baseMsg); -// }catch (Exception e1){ -// log.error("更新db状态error: ", e1); + BaseMsg baseMsg = null; + + try { + 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)); + } else if(EnumMsgRecordType.PUBLIC.getCode().equals(baseMsg.getMsgType())) { + //公众号-模板消息 + sendMpMsgService.send((MpAppMsg)JsonUtil.readValue(message,MpAppMsg.class)); + } else if(EnumMsgRecordType.SMART_APP_UNIFORM.getCode().equals(baseMsg.getMsgType())) { + //微信小程序-统一消息 + sendWeappUniformMsgService.send((AppUniformMsg)JsonUtil.readValue(message,AppUniformMsg.class)); + } + baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); + wxMsgRecordMapper.update(baseMsg); + }catch (Exception e){ + try { + log.error("consum received error:{} ", e.getMessage()); + log.error("consum received error: ", e); + //baseMsg.setStatusMessage(e.getMessage()); + baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_FAIL.getCode()); + wxMsgRecordMapper.update(baseMsg); + }catch (Exception e1){ + log.error("更新db状态error: ", e1); + } + +// if(null != 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); +// } // } -// -//// if(null != 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); -//// } -//// } -// } + } } }