Class OfflineMessageServiceImpl
java.lang.Object
com.finconsgroup.itserr.marketplace.usercommunication.dm.service.impl.OfflineMessageServiceImpl
- All Implemented Interfaces:
OfflineMessageService
@Service
@Transactional
public class OfflineMessageServiceImpl
extends Object
implements OfflineMessageService
Service implementation handling offline message queuing, notifications, and delivery.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanupOldDeliveredMessages(int daysOld) Cleanup delivered messages older than a threshold to keep storage tidy.voiddeliverOfflineMessages(UUID userId) Deliver all queued messages to a user and mark them delivered.longgetUndeliveredMessageCount(UUID userId) Count undelivered messages for a user across all conversations.longgetUndeliveredMessageCount(UUID userId, UUID conversationId) Count undelivered messages for a user in a specific conversation.getUndeliveredMessages(UUID userId) Retrieve undelivered messages for a user (oldest first).getUnreadMessageSummary(UUID userId) Get unread message summary for a uservoidhandleMessageDelivery(ChatMessage chatMessage, UUID recipientUserId) Attempt immediate delivery if user online; otherwise queue for later.booleanisUserOnline(UUID userId) Best-effort check if a user is online (e.g., via WebSocket reachability).voidnotifyUserAboutPendingMessages(UUID userId) Notify a user that they have pending messages, typically when they connect/subscribe.voidqueueMessageForOfflineUser(ChatMessage chatMessage, UUID recipientUserId) Queue a message for a recipient who is currently offline (or when direct delivery fails).voidsendOfflineMessageNotification(UUID userId) Send a generic offline notification to a user about pending messages.
-
Constructor Details
-
OfflineMessageServiceImpl
public OfflineMessageServiceImpl()
-
-
Method Details
-
queueMessageForOfflineUser
Description copied from interface:OfflineMessageServiceQueue a message for a recipient who is currently offline (or when direct delivery fails).- Specified by:
queueMessageForOfflineUserin interfaceOfflineMessageService- Parameters:
chatMessage- the message to queuerecipientUserId- the offline recipient's user ID
-
notifyUserAboutPendingMessages
Description copied from interface:OfflineMessageServiceNotify a user that they have pending messages, typically when they connect/subscribe.- Specified by:
notifyUserAboutPendingMessagesin interfaceOfflineMessageService- Parameters:
userId- the user to notify
-
deliverOfflineMessages
Description copied from interface:OfflineMessageServiceDeliver all queued messages to a user and mark them delivered.- Specified by:
deliverOfflineMessagesin interfaceOfflineMessageService- Parameters:
userId- the recipient user ID
-
isUserOnline
Description copied from interface:OfflineMessageServiceBest-effort check if a user is online (e.g., via WebSocket reachability).- Specified by:
isUserOnlinein interfaceOfflineMessageService- Parameters:
userId- the user ID- Returns:
- true if the user appears online
-
getUndeliveredMessageCount
Description copied from interface:OfflineMessageServiceCount undelivered messages for a user across all conversations.- Specified by:
getUndeliveredMessageCountin interfaceOfflineMessageService- Parameters:
userId- the user ID- Returns:
- number of undelivered messages
-
getUndeliveredMessageCount
Description copied from interface:OfflineMessageServiceCount undelivered messages for a user in a specific conversation.- Specified by:
getUndeliveredMessageCountin interfaceOfflineMessageService- Parameters:
userId- the user IDconversationId- the conversation ID- Returns:
- number of undelivered messages in the conversation
-
getUndeliveredMessages
Description copied from interface:OfflineMessageServiceRetrieve undelivered messages for a user (oldest first).- Specified by:
getUndeliveredMessagesin interfaceOfflineMessageService- Parameters:
userId- the user ID- Returns:
- list of offline message records
-
getUnreadMessageSummary
Description copied from interface:OfflineMessageServiceGet unread message summary for a user- Specified by:
getUnreadMessageSummaryin interfaceOfflineMessageService- Parameters:
userId- the user ID- Returns:
- the unread message summary
-
cleanupOldDeliveredMessages
public void cleanupOldDeliveredMessages(int daysOld) Description copied from interface:OfflineMessageServiceCleanup delivered messages older than a threshold to keep storage tidy.- Specified by:
cleanupOldDeliveredMessagesin interfaceOfflineMessageService- Parameters:
daysOld- threshold in days
-
handleMessageDelivery
Description copied from interface:OfflineMessageServiceAttempt immediate delivery if user online; otherwise queue for later.- Specified by:
handleMessageDeliveryin interfaceOfflineMessageService- Parameters:
chatMessage- the messagerecipientUserId- the recipient user ID
-
sendOfflineMessageNotification
Description copied from interface:OfflineMessageServiceSend a generic offline notification to a user about pending messages. Kept for backward compatibility; notifyUserAboutPendingMessages is preferred.- Specified by:
sendOfflineMessageNotificationin interfaceOfflineMessageService- Parameters:
userId- the user ID
-