Understand the API entry points and event model
masterThe library provides two primary ways to consume MySQL binary logs depending on your use case:
BinaryLogClient: Use this to read binary logs directly from a live MySQL server.BinaryLogFileReader: Use this for offline processing of existing binary log files.
Both entry points use an EventDeserializer to convert the raw stream into Event objects. Each Event is composed of:
EventHeader: Contains metadata such as theEventType(defaults to usingEventHeaderV4Deserializer).EventData: The actual payload of the event.
If the library encounters an event type for which no specific EventDataDeserializer is registered, it falls back to a NullEventDataDeserializer to prevent the stream from breaking.
// Conceptual usage of the two entry points
// BinaryLogClient for live streaming
BinaryLogClient client = new BinaryLogClient("host", port, "user", "password");
// BinaryLogFileReader for offline files
BinaryLogFileReader reader = new BinaryLogFileReader(new File("path/to/binlog"));