Interface OfflineMessageService
- All Known Implementing Classes:
OfflineMessageServiceImpl
public interface OfflineMessageService
Service contract for handling offline message queuing, delivery, and notifications.
-
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.
-
Method Details
-
queueMessageForOfflineUser
Queue a message for a recipient who is currently offline (or when direct delivery fails).- Parameters:
chatMessage- the message to queuerecipientUserId- the offline recipient's user ID
-
notifyUserAboutPendingMessages
Notify a user that they have pending messages, typically when they connect/subscribe.- Parameters:
userId- the user to notify
-
deliverOfflineMessages
Deliver all queued messages to a user and mark them delivered.- Parameters:
userId- the recipient user ID
-
isUserOnline
Best-effort check if a user is online (e.g., via WebSocket reachability).- Parameters:
userId- the user ID- Returns:
- true if the user appears online
-
getUndeliveredMessageCount
Count undelivered messages for a user across all conversations.- Parameters:
userId- the user ID- Returns:
- number of undelivered messages
-
getUndeliveredMessageCount
Count undelivered messages for a user in a specific conversation.- Parameters:
userId- the user IDconversationId- the conversation ID- Returns:
- number of undelivered messages in the conversation
-
getUndeliveredMessages
Retrieve undelivered messages for a user (oldest first).- Parameters:
userId- the user ID- Returns:
- list of offline message records
-
getUnreadMessageSummary
Get unread message summary for a user- Parameters:
userId- the user ID- Returns:
- the unread message summary
-
cleanupOldDeliveredMessages
void cleanupOldDeliveredMessages(int daysOld) Cleanup delivered messages older than a threshold to keep storage tidy.- Parameters:
daysOld- threshold in days
-
handleMessageDelivery
Attempt immediate delivery if user online; otherwise queue for later.- Parameters:
chatMessage- the messagerecipientUserId- the recipient user ID
-
sendOfflineMessageNotification
Send a generic offline notification to a user about pending messages. Kept for backward compatibility; notifyUserAboutPendingMessages is preferred.- Parameters:
userId- the user ID
-