Class ReplayDispatcher
java.lang.Object
org.apache.synapse.transport.http.conn.ReplayDispatcher
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. On JVM shutdown, queued records are written within a bounded time and the writer
is closed once.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddReplayRecord(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 ReplayDispatcherReturns the singleton instance of the ReplayDispatcher, creating it if necessary.voidshutdown()Stops accepting replay records, waits up to 10000L ms for the workers to write the queued records, and closes the writer once.
-
Method Details
-
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
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
-
shutdown
public void shutdown()Stops accepting replay records, waits up to 10000L ms for the workers to write the queued records, and closes the writer once. Called from a JVM shutdown hook. Calling it more than once has no effect.
-