From 5b1dc15aba3c4fb9c3ec50248639912033e53d25 Mon Sep 17 00:00:00 2001 From: Chakshu Gautam Date: Sat, 1 Apr 2023 11:58:23 +0530 Subject: [PATCH] Add logging --- .../consumers/OutboundKafkaController.java | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/uci/outbound/consumers/OutboundKafkaController.java b/src/main/java/com/uci/outbound/consumers/OutboundKafkaController.java index 469b89a..fd180c3 100644 --- a/src/main/java/com/uci/outbound/consumers/OutboundKafkaController.java +++ b/src/main/java/com/uci/outbound/consumers/OutboundKafkaController.java @@ -90,25 +90,28 @@ public void accept(Throwable e) { @Override public void accept(XMessage xMessage) { if(xMessage.getApp() != null) { - XMessageDAO dao = XMessageDAOUtils.convertXMessageToDAO(xMessage); - - redisCacheService.setXMessageDaoCache(xMessage.getTo().getUserID(), dao); - - xMessageRepo - .insert(dao) - .doOnError(new Consumer() { - @Override - public void accept(Throwable e) { - redisCacheService.deleteXMessageDaoCache(xMessage.getTo().getUserID()); - log.error("Exception in xMsg Dao Save:"+e.getMessage()); - } - }) - .subscribe(new Consumer() { - @Override - public void accept(XMessageDAO xMessageDAO) { - log.info("XMessage Object saved is with sent user ID >> " + xMessageDAO.getUserId()); - } - }); + try{ + XMessageDAO dao = XMessageDAOUtils.convertXMessageToDAO(xMessage); + redisCacheService.setXMessageDaoCache(xMessage.getTo().getUserID(), dao); + xMessageRepo + .insert(dao) + .doOnError(new Consumer() { + @Override + public void accept(Throwable e) { + redisCacheService.deleteXMessageDaoCache(xMessage.getTo().getUserID()); + log.error("Exception in xMsg Dao Save:"+e.getMessage()); + } + }) + .subscribe(new Consumer() { + @Override + public void accept(XMessageDAO xMessageDAO) { + log.info("XMessage Object saved is with sent user ID >> " + xMessageDAO.getUserId()); + } + }); + }catch(e){ + log.error("Exception in convertXMessageToDAO:" + e.getMessage()); + log.error("The current XMessage was " + xMessage.toXML()); + } } else { log.info("XMessage -> app is empty"); }