Handled notification

This commit is contained in:
rajesh
2025-09-26 20:04:33 +05:30
parent f5bf0f31af
commit 47db22e69c

View File

@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -105,7 +106,11 @@ public class NotificationDao {
String userChannel = GepafinConstant.COMMON_SINGLE_CHANNEL_PREFIX + userId; String userChannel = GepafinConstant.COMMON_SINGLE_CHANNEL_PREFIX + userId;
log.info("Channel for User {}", userChannel); log.info("Channel for User {}", userChannel);
NotificationResponse notificationResponse = convertNotificationEntityToNotificationResponse(notificationEntity); 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<Long> companyIds, NotificationEntity notificationEntity) { private void sendToCompanies(Long userId, List<Long> companyIds, NotificationEntity notificationEntity) {
@@ -120,7 +125,11 @@ public class NotificationDao {
notificationEntity.setUserWithCompany(userWithCompany); notificationEntity.setUserWithCompany(userWithCompany);
notificationRepository.save(notificationEntity); notificationRepository.save(notificationEntity);
NotificationResponse notificationResponse = convertNotificationEntityToNotificationResponse(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);
}
}); });
} }