Interface OfflineMessageService

All Known Implementing Classes:
OfflineMessageServiceImpl

public interface OfflineMessageService
Service contract for handling offline message queuing, delivery, and notifications.
  • Method Details

    • queueMessageForOfflineUser

      void queueMessageForOfflineUser(ChatMessage chatMessage, UUID recipientUserId)
      Queue a message for a recipient who is currently offline (or when direct delivery fails).
      Parameters:
      chatMessage - the message to queue
      recipientUserId - the offline recipient's user ID
    • notifyUserAboutPendingMessages

      void notifyUserAboutPendingMessages(UUID userId)
      Notify a user that they have pending messages, typically when they connect/subscribe.
      Parameters:
      userId - the user to notify
    • deliverOfflineMessages

      void deliverOfflineMessages(UUID userId)
      Deliver all queued messages to a user and mark them delivered.
      Parameters:
      userId - the recipient user ID
    • isUserOnline

      boolean isUserOnline(UUID userId)
      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

      long getUndeliveredMessageCount(UUID userId)
      Count undelivered messages for a user across all conversations.
      Parameters:
      userId - the user ID
      Returns:
      number of undelivered messages
    • getUndeliveredMessageCount

      long getUndeliveredMessageCount(UUID userId, UUID conversationId)
      Count undelivered messages for a user in a specific conversation.
      Parameters:
      userId - the user ID
      conversationId - the conversation ID
      Returns:
      number of undelivered messages in the conversation
    • getUndeliveredMessages

      List<OfflineMessage> getUndeliveredMessages(UUID userId)
      Retrieve undelivered messages for a user (oldest first).
      Parameters:
      userId - the user ID
      Returns:
      list of offline message records
    • getUnreadMessageSummary

      OutputUnreadMessageSummaryDto getUnreadMessageSummary(UUID userId)
      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

      void handleMessageDelivery(ChatMessage chatMessage, UUID recipientUserId)
      Attempt immediate delivery if user online; otherwise queue for later.
      Parameters:
      chatMessage - the message
      recipientUserId - the recipient user ID
    • sendOfflineMessageNotification

      void sendOfflineMessageNotification(UUID userId)
      Send a generic offline notification to a user about pending messages. Kept for backward compatibility; notifyUserAboutPendingMessages is preferred.
      Parameters:
      userId - the user ID