Handled notification
This commit is contained in:
@@ -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);
|
||||||
|
try {
|
||||||
messagingTemplate.convertAndSend(userChannel, notificationResponse);
|
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);
|
||||||
|
try {
|
||||||
messagingTemplate.convertAndSend(companyChannel, notificationResponse);
|
messagingTemplate.convertAndSend(companyChannel, notificationResponse);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error while sending the notification {0}", e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user