Class ReplayDispatcher


  • public class ReplayDispatcher
    extends Object
    Singleton manager class responsible for buffering replay data and asynchronously writing it to a configured ReplayDataWriter. A dedicated background thread consumes records from the queue and writes them using the ReplayDataWriter implementation configured dynamically through properties. This class is thread-safe and supports graceful shutdown by closing the writer and stopping the background thread.
    • Method Detail

      • getInstance

        public static ReplayDispatcher getInstance()
        Returns the singleton instance of the ReplayDispatcher, creating it if necessary. Dynamically instantiates the writer class configured via properties. Throws an IllegalStateException for missing or invalid configuration.
        Returns:
        singleton instance of this dispatcher
      • addReplayRecord

        public void addReplayRecord​(String messageId,
                                    Map<String,​Object> metadata,
                                    byte[] data)
        Adds a replay record to the internal buffer queue for later asynchronous writing. If the queue is full, drops the message and logs drop occurrences at configured frequency.
        Parameters:
        messageId - unique identifier of the message
        metadata - metadata map describing contextual information of the message
        data - raw byte array of the message content
      • addReplayRecord

        public void addReplayRecord​(ByteBuffer dataBuffer,
                                    int byteWritten,
                                    String messageId,
                                    Map<String,​Object> metadata)
        Convenience method to wrap data in ByteBuffer and delegate to addReplayRecord(String, byte[], Map).
        Parameters:
        dataBuffer - byte buffer containing the raw message data
        byteWritten - number of bytes written to the buffer
        messageId - unique message identifier
        metadata - metadata map for contextual information