将无法处理的消息错误写日志。同时更新该消息为已处理状态

This commit is contained in:
zhouxiunai
2018-12-26 17:16:02 +08:00
parent f053d84817
commit 233cd0d036
@@ -1,7 +1,7 @@
package com.gzzn.omms.msgexchangeapi.msghandler; package com.gzzn.omms.msgexchangeapi.msghandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Arrays;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg; import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.entity.msg.MSG; import com.gzzn.omms.msgexchangeapi.entity.msg.MSG;
import com.gzzn.omms.msgexchangeapi.service.ICminmsgService;
import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService; import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService;
@Service("msgHandlerDispatcher") @Service("msgHandlerDispatcher")
@@ -19,6 +20,9 @@ public class MsgHandlerDispatcher {
@Autowired @Autowired
IExchangeService exchangeService; IExchangeService exchangeService;
@Autowired
ICminmsgService cminmsgService;
public HandlerResult dispatch(Cminmsg cminmsg) public HandlerResult dispatch(Cminmsg cminmsg)
{ {
try try
@@ -34,7 +38,14 @@ public class MsgHandlerDispatcher {
return result; return result;
} catch (Exception e) { } catch (Exception e) {
//throw new RuntimeException(e); //throw new RuntimeException(e);
logger.error("消息处理失败msg:{},err:{}",cminmsg.getCminmsgsClobMsg(),e.getMessage()); try
{
cminmsgService.updateBatchProcessed(Arrays.asList(cminmsg));//更新为已处理
logger.error("消息处理失败msg:{},err:{}",cminmsg.getCminmsgsClobMsg(),e.getMessage());
}
catch (Exception e1) {
logger.error("消err:{}",e1.getMessage());
}
return HandlerResult.failure(); return HandlerResult.failure();
} }
}//end function }//end function