diff --git a/src/main/java/net/gepafin/tendermanagement/dao/NotificationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/NotificationDao.java index 55ec6665..57236418 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/NotificationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/NotificationDao.java @@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.jpa.domain.Specification; +import org.springframework.messaging.MessagingException; import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.stereotype.Component; @@ -105,7 +106,11 @@ public class NotificationDao { String userChannel = GepafinConstant.COMMON_SINGLE_CHANNEL_PREFIX + userId; log.info("Channel for User {}", userChannel); NotificationResponse notificationResponse = convertNotificationEntityToNotificationResponse(notificationEntity); - messagingTemplate.convertAndSend(userChannel, notificationResponse); + try { + messagingTemplate.convertAndSend(userChannel, notificationResponse); + } catch (Exception e) { + log.error("Error while sending the notification {0}", e); + } } private void sendToCompanies(Long userId, List companyIds, NotificationEntity notificationEntity) { @@ -120,7 +125,11 @@ public class NotificationDao { notificationEntity.setUserWithCompany(userWithCompany); notificationRepository.save(notificationEntity); NotificationResponse notificationResponse = convertNotificationEntityToNotificationResponse(notificationEntity); - messagingTemplate.convertAndSend(companyChannel, notificationResponse); + try { + messagingTemplate.convertAndSend(companyChannel, notificationResponse); + } catch (Exception e) { + log.error("Error while sending the notification {0}", e); + } }); }