Class ReplayDispatcher
- java.lang.Object
-
- org.apache.synapse.transport.http.conn.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReplayRecord(String messageId, Map<String,Object> metadata, byte[] data)Adds a replay record to the internal buffer queue for later asynchronous writing.voidaddReplayRecord(ByteBuffer dataBuffer, int byteWritten, String messageId, Map<String,Object> metadata)Convenience method to wrap data in ByteBuffer and delegate to addReplayRecord(String, byte[], Map).static ReplayDispatchergetInstance()Returns the singleton instance of the ReplayDispatcher, creating it if necessary.
-
-
-
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 messagemetadata- metadata map describing contextual information of the messagedata- 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 databyteWritten- number of bytes written to the buffermessageId- unique message identifiermetadata- metadata map for contextual information
-
-